mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
php csfixes
This commit is contained in:
parent
416a88b93d
commit
e19cac168b
@ -87,12 +87,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
*/
|
*/
|
||||||
private CommentEmbeddable $comment;
|
private CommentEmbeddable $comment;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
|
||||||
* @Groups({"docgen:read"})
|
|
||||||
*/
|
|
||||||
private PrivateCommentEmbeddable $privateComment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetime")
|
* @ORM\Column(type="datetime")
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
@ -141,6 +135,12 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
*/
|
*/
|
||||||
private ?Collection $persons = null;
|
private ?Collection $persons = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
||||||
|
* @Groups({"docgen:read"})
|
||||||
|
*/
|
||||||
|
private PrivateCommentEmbeddable $privateComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
* @ORM\ManyToMany(targetEntity="Chill\ActivityBundle\Entity\ActivityReason")
|
||||||
* @Groups({"docgen:read"})
|
* @Groups({"docgen:read"})
|
||||||
@ -321,11 +321,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this->comment;
|
return $this->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
|
||||||
{
|
|
||||||
return $this->privateComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDate(): DateTime
|
public function getDate(): DateTime
|
||||||
{
|
{
|
||||||
return $this->date;
|
return $this->date;
|
||||||
@ -413,6 +408,11 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||||
|
{
|
||||||
|
return $this->privateComment;
|
||||||
|
}
|
||||||
|
|
||||||
public function getReasons(): Collection
|
public function getReasons(): Collection
|
||||||
{
|
{
|
||||||
return $this->reasons;
|
return $this->reasons;
|
||||||
@ -550,13 +550,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
|
||||||
{
|
|
||||||
$this->privateComment = $privateComment;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDate(DateTime $date): self
|
public function setDate(DateTime $date): self
|
||||||
{
|
{
|
||||||
$this->date = $date;
|
$this->date = $date;
|
||||||
@ -606,6 +599,13 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||||
|
{
|
||||||
|
$this->privateComment = $privateComment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setReasons(?ArrayCollection $reasons): self
|
public function setReasons(?ArrayCollection $reasons): self
|
||||||
{
|
{
|
||||||
$this->reasons = $reasons;
|
$this->reasons = $reasons;
|
||||||
|
@ -76,16 +76,6 @@ class ActivityType
|
|||||||
*/
|
*/
|
||||||
private int $commentVisible = self::FIELD_OPTIONAL;
|
private int $commentVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
|
||||||
*/
|
|
||||||
private string $privateCommentLabel = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
|
||||||
*/
|
|
||||||
private int $privateCommentVisible = self::FIELD_OPTIONAL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||||
*/
|
*/
|
||||||
@ -177,6 +167,16 @@ class ActivityType
|
|||||||
*/
|
*/
|
||||||
private int $personVisible = self::FIELD_REQUIRED;
|
private int $personVisible = self::FIELD_REQUIRED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||||
|
*/
|
||||||
|
private string $privateCommentLabel = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="smallint", nullable=false, options={"default": 1})
|
||||||
|
*/
|
||||||
|
private int $privateCommentVisible = self::FIELD_OPTIONAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
* @ORM\Column(type="string", nullable=false, options={"default": ""})
|
||||||
*/
|
*/
|
||||||
@ -324,16 +324,6 @@ class ActivityType
|
|||||||
return $this->commentVisible;
|
return $this->commentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrivateCommentLabel(): string
|
|
||||||
{
|
|
||||||
return $this->privateCommentLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrivateCommentVisible(): int
|
|
||||||
{
|
|
||||||
return $this->privateCommentVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDateLabel(): string
|
public function getDateLabel(): string
|
||||||
{
|
{
|
||||||
return $this->dateLabel;
|
return $this->dateLabel;
|
||||||
@ -436,6 +426,16 @@ class ActivityType
|
|||||||
return $this->personVisible;
|
return $this->personVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrivateCommentLabel(): string
|
||||||
|
{
|
||||||
|
return $this->privateCommentLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrivateCommentVisible(): int
|
||||||
|
{
|
||||||
|
return $this->privateCommentVisible;
|
||||||
|
}
|
||||||
|
|
||||||
public function getReasonsLabel(): string
|
public function getReasonsLabel(): string
|
||||||
{
|
{
|
||||||
return $this->reasonsLabel;
|
return $this->reasonsLabel;
|
||||||
@ -593,20 +593,6 @@ class ActivityType
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrivateCommentLabel(string $privateCommentLabel): self
|
|
||||||
{
|
|
||||||
$this->privateCommentLabel = $privateCommentLabel;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPrivateCommentVisible(int $privateCommentVisible): self
|
|
||||||
{
|
|
||||||
$this->privateCommentVisible = $privateCommentVisible;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDateLabel(string $dateLabel): self
|
public function setDateLabel(string $dateLabel): self
|
||||||
{
|
{
|
||||||
$this->dateLabel = $dateLabel;
|
$this->dateLabel = $dateLabel;
|
||||||
@ -722,6 +708,20 @@ class ActivityType
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPrivateCommentLabel(string $privateCommentLabel): self
|
||||||
|
{
|
||||||
|
$this->privateCommentLabel = $privateCommentLabel;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPrivateCommentVisible(int $privateCommentVisible): self
|
||||||
|
{
|
||||||
|
$this->privateCommentVisible = $privateCommentVisible;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setReasonsLabel(string $reasonsLabel): self
|
public function setReasonsLabel(string $reasonsLabel): self
|
||||||
{
|
{
|
||||||
$this->reasonsLabel = $reasonsLabel;
|
$this->reasonsLabel = $reasonsLabel;
|
||||||
|
@ -255,7 +255,7 @@ class ActivityType extends AbstractType
|
|||||||
if ($activityType->isVisible('privateComment')) {
|
if ($activityType->isVisible('privateComment')) {
|
||||||
$builder->add('privateComment', PrivateCommentType::class, [
|
$builder->add('privateComment', PrivateCommentType::class, [
|
||||||
'label' => empty($activityType->getLabel('privateComment')) ? 'activity.private comment' : $activityType->getPrivateCommentLabel(),
|
'label' => empty($activityType->getLabel('privateComment')) ? 'activity.private comment' : $activityType->getPrivateCommentLabel(),
|
||||||
'required' => false
|
'required' => false,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Activity;
|
namespace Chill\Migrations\Activity;
|
||||||
@ -12,6 +19,13 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
*/
|
*/
|
||||||
final class Version20220425133027 extends AbstractMigration
|
final class Version20220425133027 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE activitytype DROP privateCommentLabel');
|
||||||
|
$this->addSql('ALTER TABLE activitytype DROP privateCommentVisible');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'add private comment option to activity types';
|
return 'add private comment option to activity types';
|
||||||
@ -23,11 +37,4 @@ final class Version20220425133027 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE activitytype ADD privateCommentLabel VARCHAR(255) DEFAULT \'\' NOT NULL');
|
$this->addSql('ALTER TABLE activitytype ADD privateCommentLabel VARCHAR(255) DEFAULT \'\' NOT NULL');
|
||||||
$this->addSql('ALTER TABLE activitytype ADD privateCommentVisible SMALLINT DEFAULT 1 NOT NULL');
|
$this->addSql('ALTER TABLE activitytype ADD privateCommentVisible SMALLINT DEFAULT 1 NOT NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE activitytype DROP privateCommentLabel');
|
|
||||||
$this->addSql('ALTER TABLE activitytype DROP privateCommentVisible');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -71,12 +71,6 @@ class Calendar
|
|||||||
*/
|
*/
|
||||||
private CommentEmbeddable $comment;
|
private CommentEmbeddable $comment;
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
|
|
||||||
* @Serializer\Groups({"calendar:read"})
|
|
||||||
*/
|
|
||||||
private PrivateCommentEmbeddable $privateComment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="datetimetz_immutable")
|
* @ORM\Column(type="datetimetz_immutable")
|
||||||
* @Serializer\Groups({"calendar:read"})
|
* @Serializer\Groups({"calendar:read"})
|
||||||
@ -122,6 +116,12 @@ class Calendar
|
|||||||
*/
|
*/
|
||||||
private Collection $persons;
|
private Collection $persons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
|
||||||
|
* @Serializer\Groups({"calendar:read"})
|
||||||
|
*/
|
||||||
|
private PrivateCommentEmbeddable $privateComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(
|
* @ORM\ManyToMany(
|
||||||
* targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty",
|
* targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty",
|
||||||
@ -216,11 +216,6 @@ class Calendar
|
|||||||
return $this->comment;
|
return $this->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
|
||||||
{
|
|
||||||
return $this->privateComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEndDate(): ?DateTimeImmutable
|
public function getEndDate(): ?DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->endDate;
|
return $this->endDate;
|
||||||
@ -291,6 +286,11 @@ class Calendar
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||||
|
{
|
||||||
|
return $this->privateComment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|ThirdParty[]
|
* @return Collection|ThirdParty[]
|
||||||
*/
|
*/
|
||||||
@ -399,13 +399,6 @@ class Calendar
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
|
||||||
{
|
|
||||||
$this->privateComment = $privateComment;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setEndDate(DateTimeImmutable $endDate): self
|
public function setEndDate(DateTimeImmutable $endDate): self
|
||||||
{
|
{
|
||||||
$this->endDate = $endDate;
|
$this->endDate = $endDate;
|
||||||
@ -427,6 +420,13 @@ class Calendar
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||||
|
{
|
||||||
|
$this->privateComment = $privateComment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setSendSMS(?bool $sendSMS): self
|
public function setSendSMS(?bool $sendSMS): self
|
||||||
{
|
{
|
||||||
$this->sendSMS = $sendSMS;
|
$this->sendSMS = $sendSMS;
|
||||||
|
@ -54,7 +54,7 @@ class CalendarType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('privateComment', PrivateCommentType::class, [
|
->add('privateComment', PrivateCommentType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => 'private comment'
|
'label' => 'private comment',
|
||||||
])
|
])
|
||||||
// ->add('cancelReason', EntityType::class, [
|
// ->add('cancelReason', EntityType::class, [
|
||||||
// 'required' => false,
|
// 'required' => false,
|
||||||
|
@ -24,15 +24,25 @@ class PrivateCommentEmbeddable
|
|||||||
*/
|
*/
|
||||||
private ?array $comments = [];
|
private ?array $comments = [];
|
||||||
|
|
||||||
|
public function getCommentForUser(User $user): string
|
||||||
|
{
|
||||||
|
return $this->comments[$user->getId()] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
public function getComments(): ?array
|
public function getComments(): ?array
|
||||||
{
|
{
|
||||||
return $this->comments;
|
return $this->comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function merge(PrivateCommentEmbeddable $newComment): self
|
||||||
public function getCommentForUser(User $user): string
|
|
||||||
{
|
{
|
||||||
return $this->comments[$user->getId()] ?? '';
|
$currentComments = null === $this->getComments() ? [] : $this->getComments();
|
||||||
|
|
||||||
|
$mergedComments = $newComment->getComments() + $currentComments;
|
||||||
|
|
||||||
|
$this->setComments($mergedComments);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCommentForUser(User $user, string $content): self
|
public function setCommentForUser(User $user, string $content): self
|
||||||
@ -48,16 +58,4 @@ class PrivateCommentEmbeddable
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function merge(PrivateCommentEmbeddable $newComment): self
|
|
||||||
{
|
|
||||||
|
|
||||||
$currentComments = null === $this->getComments() ? [] : $this->getComments();
|
|
||||||
|
|
||||||
$mergedComments = $newComment->getComments() + $currentComments;
|
|
||||||
|
|
||||||
$this->setComments($mergedComments);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ use Symfony\Component\Security\Core\Security;
|
|||||||
|
|
||||||
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
|
final class PrivateCommentDataMapper extends AbstractType implements DataMapperInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
public function __construct(Security $security)
|
public function __construct(Security $security)
|
||||||
@ -40,8 +39,6 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI
|
|||||||
$forms = iterator_to_array($forms);
|
$forms = iterator_to_array($forms);
|
||||||
|
|
||||||
$forms['comments']->setData($viewData->getCommentForUser($this->security->getUser()));
|
$forms['comments']->setData($viewData->getCommentForUser($this->security->getUser()));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mapFormsToData($forms, &$viewData)
|
public function mapFormsToData($forms, &$viewData)
|
||||||
@ -50,5 +47,4 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI
|
|||||||
|
|
||||||
$viewData->setCommentForUser($this->security->getUser(), $forms['comments']->getData());
|
$viewData->setCommentForUser($this->security->getUser(), $forms['comments']->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -11,17 +11,11 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Form\Type;
|
namespace Chill\MainBundle\Form\Type;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||||
use Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper;
|
use Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper;
|
||||||
use DateTime;
|
|
||||||
|
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\Form\FormEvent;
|
|
||||||
use Symfony\Component\Form\FormEvents;
|
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\Form\FormView;
|
use Symfony\Component\Form\FormView;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
@ -30,10 +24,10 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
|||||||
|
|
||||||
class PrivateCommentType extends AbstractType
|
class PrivateCommentType extends AbstractType
|
||||||
{
|
{
|
||||||
protected UserInterface $user;
|
|
||||||
|
|
||||||
protected PrivateCommentDataMapper $dataMapper;
|
protected PrivateCommentDataMapper $dataMapper;
|
||||||
|
|
||||||
|
protected UserInterface $user;
|
||||||
|
|
||||||
public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper)
|
public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper)
|
||||||
{
|
{
|
||||||
$this->user = $tokenStorage->getToken()->getUser();
|
$this->user = $tokenStorage->getToken()->getUser();
|
||||||
@ -44,7 +38,7 @@ class PrivateCommentType extends AbstractType
|
|||||||
{
|
{
|
||||||
$builder
|
$builder
|
||||||
->add('comments', ChillTextareaType::class, [
|
->add('comments', ChillTextareaType::class, [
|
||||||
'label' => 'private comment'
|
'label' => 'private comment',
|
||||||
])
|
])
|
||||||
->setDataMapper($this->dataMapper);
|
->setDataMapper($this->dataMapper);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||||
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||||
@ -19,7 +18,6 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|||||||
|
|
||||||
class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, DenormalizerInterface
|
class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, DenormalizerInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
private Security $security;
|
private Security $security;
|
||||||
|
|
||||||
public function __construct(Security $security)
|
public function __construct(Security $security)
|
||||||
@ -40,19 +38,18 @@ class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, Denorma
|
|||||||
return $comment;
|
return $comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportsDenormalization($data, string $type, ?string $format = null): bool
|
|
||||||
{
|
|
||||||
return $type === PrivateCommentEmbeddable::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function normalize($comment, $format = null, array $contect = []): string
|
public function normalize($comment, $format = null, array $contect = []): string
|
||||||
{
|
{
|
||||||
return $comment->getCommentForUser($this->security->getUser());
|
return $comment->getCommentForUser($this->security->getUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsDenormalization($data, string $type, ?string $format = null): bool
|
||||||
|
{
|
||||||
|
return PrivateCommentEmbeddable::class === $type;
|
||||||
|
}
|
||||||
|
|
||||||
public function supportsNormalization($data, ?string $format = null): bool
|
public function supportsNormalization($data, ?string $format = null): bool
|
||||||
{
|
{
|
||||||
return $data instanceof PrivateCommentEmbeddable;
|
return $data instanceof PrivateCommentEmbeddable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Main;
|
namespace Chill\Migrations\Main;
|
||||||
@ -12,6 +19,14 @@ use Doctrine\Migrations\AbstractMigration;
|
|||||||
*/
|
*/
|
||||||
final class Version20220426133048 extends AbstractMigration
|
final class Version20220426133048 extends AbstractMigration
|
||||||
{
|
{
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP privateComment_comments');
|
||||||
|
$this->addSql('ALTER TABLE activity DROP privateComment_comments');
|
||||||
|
$this->addSql('ALTER TABLE chill_calendar.calendar DROP privateComment_comments');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'add private embeddable comment to activity, calendar and accompanyingperiod work';
|
return 'add private embeddable comment to activity, calendar and accompanyingperiod work';
|
||||||
@ -24,12 +39,4 @@ final class Version20220426133048 extends AbstractMigration
|
|||||||
$this->addSql('ALTER TABLE chill_calendar.calendar ADD privateComment_comments JSON DEFAULT NULL');
|
$this->addSql('ALTER TABLE chill_calendar.calendar ADD privateComment_comments JSON DEFAULT NULL');
|
||||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD privateComment_comments JSON DEFAULT NULL');
|
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD privateComment_comments JSON DEFAULT NULL');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
// this down() migration is auto-generated, please modify it to your needs
|
|
||||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP privateComment_comments');
|
|
||||||
$this->addSql('ALTER TABLE activity DROP privateComment_comments');
|
|
||||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP privateComment_comments');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
|
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
|
||||||
@ -136,12 +135,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
|||||||
*/
|
*/
|
||||||
private string $note = '';
|
private string $note = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
|
||||||
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
|
||||||
*/
|
|
||||||
private PrivateCommentEmbeddable $privateComment;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=Person::class)
|
* @ORM\ManyToMany(targetEntity=Person::class)
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_person")
|
||||||
@ -151,6 +144,12 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
|||||||
*/
|
*/
|
||||||
private Collection $persons;
|
private Collection $persons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
||||||
|
* @Serializer\Groups({"read", "accompanying_period_work:edit"})
|
||||||
|
*/
|
||||||
|
private PrivateCommentEmbeddable $privateComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToMany(targetEntity=User::class)
|
* @ORM\ManyToMany(targetEntity=User::class)
|
||||||
* @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
|
* @ORM\JoinTable(name="chill_person_accompanying_period_work_referrer")
|
||||||
@ -332,16 +331,16 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
|||||||
return $this->note;
|
return $this->note;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
|
||||||
{
|
|
||||||
return $this->privateComment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPersons(): Collection
|
public function getPersons(): Collection
|
||||||
{
|
{
|
||||||
return $this->persons;
|
return $this->persons;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||||
|
{
|
||||||
|
return $this->privateComment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|User[]
|
* @return Collection|User[]
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user