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;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_")
|
||||
* @Groups({"docgen:read"})
|
||||
*/
|
||||
private PrivateCommentEmbeddable $privateComment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
* @Groups({"docgen:read"})
|
||||
@ -141,6 +135,12 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
*/
|
||||
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")
|
||||
* @Groups({"docgen:read"})
|
||||
@ -321,11 +321,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
public function getDate(): DateTime
|
||||
{
|
||||
return $this->date;
|
||||
@ -413,6 +408,11 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
public function getReasons(): Collection
|
||||
{
|
||||
return $this->reasons;
|
||||
@ -550,13 +550,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||
{
|
||||
$this->privateComment = $privateComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDate(DateTime $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
@ -606,6 +599,13 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||
{
|
||||
$this->privateComment = $privateComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setReasons(?ArrayCollection $reasons): self
|
||||
{
|
||||
$this->reasons = $reasons;
|
||||
|
@ -76,16 +76,6 @@ class ActivityType
|
||||
*/
|
||||
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": ""})
|
||||
*/
|
||||
@ -177,6 +167,16 @@ class ActivityType
|
||||
*/
|
||||
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": ""})
|
||||
*/
|
||||
@ -324,16 +324,6 @@ class ActivityType
|
||||
return $this->commentVisible;
|
||||
}
|
||||
|
||||
public function getPrivateCommentLabel(): string
|
||||
{
|
||||
return $this->privateCommentLabel;
|
||||
}
|
||||
|
||||
public function getPrivateCommentVisible(): int
|
||||
{
|
||||
return $this->privateCommentVisible;
|
||||
}
|
||||
|
||||
public function getDateLabel(): string
|
||||
{
|
||||
return $this->dateLabel;
|
||||
@ -436,6 +426,16 @@ class ActivityType
|
||||
return $this->personVisible;
|
||||
}
|
||||
|
||||
public function getPrivateCommentLabel(): string
|
||||
{
|
||||
return $this->privateCommentLabel;
|
||||
}
|
||||
|
||||
public function getPrivateCommentVisible(): int
|
||||
{
|
||||
return $this->privateCommentVisible;
|
||||
}
|
||||
|
||||
public function getReasonsLabel(): string
|
||||
{
|
||||
return $this->reasonsLabel;
|
||||
@ -593,20 +593,6 @@ class ActivityType
|
||||
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
|
||||
{
|
||||
$this->dateLabel = $dateLabel;
|
||||
@ -722,6 +708,20 @@ class ActivityType
|
||||
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
|
||||
{
|
||||
$this->reasonsLabel = $reasonsLabel;
|
||||
|
@ -252,10 +252,10 @@ class ActivityType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
if($activityType->isVisible('privateComment')) {
|
||||
if ($activityType->isVisible('privateComment')) {
|
||||
$builder->add('privateComment', PrivateCommentType::class, [
|
||||
'label' => empty($activityType->getLabel('privateComment')) ? 'activity.private comment' : $activityType->getPrivateCommentLabel(),
|
||||
'required' => false
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?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);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
@ -12,6 +19,13 @@ use Doctrine\Migrations\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
|
||||
{
|
||||
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 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;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private PrivateCommentEmbeddable $privateComment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetimetz_immutable")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
@ -122,6 +116,12 @@ class Calendar
|
||||
*/
|
||||
private Collection $persons;
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
|
||||
* @Serializer\Groups({"calendar:read"})
|
||||
*/
|
||||
private PrivateCommentEmbeddable $privateComment;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty",
|
||||
@ -216,11 +216,6 @@ class Calendar
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
public function getEndDate(): ?DateTimeImmutable
|
||||
{
|
||||
return $this->endDate;
|
||||
@ -291,6 +286,11 @@ class Calendar
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|ThirdParty[]
|
||||
*/
|
||||
@ -399,13 +399,6 @@ class Calendar
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||
{
|
||||
$this->privateComment = $privateComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEndDate(DateTimeImmutable $endDate): self
|
||||
{
|
||||
$this->endDate = $endDate;
|
||||
@ -427,6 +420,13 @@ class Calendar
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setPrivateComment(PrivateCommentEmbeddable $privateComment): self
|
||||
{
|
||||
$this->privateComment = $privateComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setSendSMS(?bool $sendSMS): self
|
||||
{
|
||||
$this->sendSMS = $sendSMS;
|
||||
|
@ -54,7 +54,7 @@ class CalendarType extends AbstractType
|
||||
])
|
||||
->add('privateComment', PrivateCommentType::class, [
|
||||
'required' => false,
|
||||
'label' => 'private comment'
|
||||
'label' => 'private comment',
|
||||
])
|
||||
// ->add('cancelReason', EntityType::class, [
|
||||
// 'required' => false,
|
||||
|
@ -24,15 +24,25 @@ class PrivateCommentEmbeddable
|
||||
*/
|
||||
private ?array $comments = [];
|
||||
|
||||
public function getCommentForUser(User $user): string
|
||||
{
|
||||
return $this->comments[$user->getId()] ?? '';
|
||||
}
|
||||
|
||||
public function getComments(): ?array
|
||||
{
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
|
||||
public function getCommentForUser(User $user): string
|
||||
public function merge(PrivateCommentEmbeddable $newComment): self
|
||||
{
|
||||
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
|
||||
@ -48,16 +58,4 @@ class PrivateCommentEmbeddable
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
@ -40,8 +39,6 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
$forms['comments']->setData($viewData->getCommentForUser($this->security->getUser()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function mapFormsToData($forms, &$viewData)
|
||||
@ -50,5 +47,4 @@ final class PrivateCommentDataMapper extends AbstractType implements DataMapperI
|
||||
|
||||
$viewData->setCommentForUser($this->security->getUser(), $forms['comments']->getData());
|
||||
}
|
||||
|
||||
}
|
@ -11,17 +11,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Form\Type;
|
||||
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||
use Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper;
|
||||
use DateTime;
|
||||
|
||||
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\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
@ -30,10 +24,10 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class PrivateCommentType extends AbstractType
|
||||
{
|
||||
protected UserInterface $user;
|
||||
|
||||
protected PrivateCommentDataMapper $dataMapper;
|
||||
|
||||
protected UserInterface $user;
|
||||
|
||||
public function __construct(TokenStorageInterface $tokenStorage, PrivateCommentDataMapper $dataMapper)
|
||||
{
|
||||
$this->user = $tokenStorage->getToken()->getUser();
|
||||
@ -44,7 +38,7 @@ class PrivateCommentType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('comments', ChillTextareaType::class, [
|
||||
'label' => 'private comment'
|
||||
'label' => 'private comment',
|
||||
])
|
||||
->setDataMapper($this->dataMapper);
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
@ -19,7 +18,6 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, DenormalizerInterface
|
||||
{
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
@ -40,19 +38,18 @@ class PrivateCommentEmbeddableNormalizer implements NormalizerInterface, Denorma
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return $data instanceof PrivateCommentEmbeddable;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,12 @@
|
||||
<?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);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
@ -12,6 +19,14 @@ use Doctrine\Migrations\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
|
||||
{
|
||||
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_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\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\PersonBundle\AccompanyingPeriod\SocialIssueConsistency\AccompanyingPeriodLinkedWithSocialIssuesEntityInterface;
|
||||
@ -136,12 +135,6 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
*/
|
||||
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\JoinTable(name="chill_person_accompanying_period_work_person")
|
||||
@ -151,6 +144,12 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
*/
|
||||
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\JoinTable(name="chill_person_accompanying_period_work_referrer")
|
||||
@ -332,16 +331,16 @@ class AccompanyingPeriodWork implements AccompanyingPeriodLinkedWithSocialIssues
|
||||
return $this->note;
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
public function getPersons(): Collection
|
||||
{
|
||||
return $this->persons;
|
||||
}
|
||||
|
||||
public function getPrivateComment(): PrivateCommentEmbeddable
|
||||
{
|
||||
return $this->privateComment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection|User[]
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user