mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-15 03:04:58 +00:00
Compare commits
26 Commits
v3.0.0-RC6
...
v3.0.0
Author | SHA1 | Date | |
---|---|---|---|
94d6b5eff8 | |||
d87f380f16 | |||
58bf722fae | |||
50fb79ebbf | |||
58912f1d98 | |||
9604ba5f4b | |||
b689a51a48 | |||
8c0d2f58ba | |||
212230448b | |||
2bfb8fe387 | |||
6362b98a00 | |||
6e2a08cae8 | |||
305105faae | |||
85811cc6ae | |||
7eee995627 | |||
c0c448fb39 | |||
6445342136 | |||
d52e54fd2a | |||
547a9d1369 | |||
288a02f5b7 | |||
2f9884072c | |||
ee45ff61a6 | |||
5dfd8daf3a | |||
a46e987f81 | |||
81220b5b22 | |||
5b0019cde7 |
5
.changes/v3.0.0.md
Normal file
5
.changes/v3.0.0.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
## v3.0.0 - 2024-08-26
|
||||||
|
### Fixed
|
||||||
|
* Fix delete action for accompanying periods in draft state
|
||||||
|
* Fix connection to azure when making an calendar event in chill
|
||||||
|
* CollectionType js fixes for remove button and adding multiple entries
|
@@ -138,4 +138,4 @@ release:
|
|||||||
- echo "running release_job"
|
- echo "running release_job"
|
||||||
release:
|
release:
|
||||||
tag_name: '$CI_COMMIT_TAG'
|
tag_name: '$CI_COMMIT_TAG'
|
||||||
description: "./.changes/v$CI_COMMIT_TAG.md"
|
description: "./.changes/$CI_COMMIT_TAG.md"
|
||||||
|
@@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
|||||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||||
|
|
||||||
|
|
||||||
|
## v3.0.0 - 2024-08-26
|
||||||
|
### Fixed
|
||||||
|
* Fix delete action for accompanying periods in draft state
|
||||||
|
* Fix connection to azure when making an calendar event in chill
|
||||||
|
* CollectionType js fixes for remove button and adding multiple entries
|
||||||
|
|
||||||
## v2.23.0 - 2024-07-23
|
## v2.23.0 - 2024-07-23
|
||||||
### Feature
|
### Feature
|
||||||
* ([#221](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/221)) [DX] move async-upload-bundle features into chill-bundles
|
* ([#221](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/221)) [DX] move async-upload-bundle features into chill-bundles
|
||||||
|
@@ -73,7 +73,7 @@ final readonly class PeriodHavingActivityBetweenDatesFilter implements FilterInt
|
|||||||
|
|
||||||
$qb->andWhere(
|
$qb->andWhere(
|
||||||
$qb->expr()->exists(
|
$qb->expr()->exists(
|
||||||
'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = acp"
|
'SELECT 1 FROM '.Activity::class." {$alias} WHERE {$alias}.date >= :{$from} AND {$alias}.date < :{$to} AND {$alias}.accompanyingPeriod = activity.accompanyingPeriod"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ final class CalendarContextTest extends TestCase
|
|||||||
{
|
{
|
||||||
$expected =
|
$expected =
|
||||||
[
|
[
|
||||||
'track_datetime' => true,
|
'trackDatetime' => true,
|
||||||
'askMainPerson' => true,
|
'askMainPerson' => true,
|
||||||
'mainPersonLabel' => 'docgen.calendar.Destinee',
|
'mainPersonLabel' => 'docgen.calendar.Destinee',
|
||||||
'askThirdParty' => false,
|
'askThirdParty' => false,
|
||||||
@@ -61,7 +61,7 @@ final class CalendarContextTest extends TestCase
|
|||||||
{
|
{
|
||||||
$expected =
|
$expected =
|
||||||
[
|
[
|
||||||
'track_datetime' => true,
|
'trackDatetime' => true,
|
||||||
'askMainPerson' => true,
|
'askMainPerson' => true,
|
||||||
'mainPersonLabel' => 'docgen.calendar.Destinee',
|
'mainPersonLabel' => 'docgen.calendar.Destinee',
|
||||||
'askThirdParty' => false,
|
'askThirdParty' => false,
|
||||||
|
@@ -53,14 +53,17 @@ export const handleAdd = (button: any): void => {
|
|||||||
let
|
let
|
||||||
empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'),
|
empty_explain: HTMLLIElement | null = collection.querySelector('li[data-collection-empty-explain]'),
|
||||||
entry = document.createElement('li'),
|
entry = document.createElement('li'),
|
||||||
counter = collection.childNodes.length + 1,
|
counter = collection.querySelectorAll('li.entry').length, // Updated counter logic
|
||||||
content = prototype.replace(new RegExp('__name__', 'g'), counter.toString()),
|
content = prototype.replace(/__name__/g, counter.toString()),
|
||||||
event = new CustomEvent('collection-add-entry', {detail: new CollectionEventPayload(collection, entry)});
|
event = new CustomEvent('collection-add-entry', {detail: new CollectionEventPayload(collection, entry)});
|
||||||
|
|
||||||
|
console.log(counter)
|
||||||
|
console.log(content)
|
||||||
|
|
||||||
entry.innerHTML = content;
|
entry.innerHTML = content;
|
||||||
entry.classList.add('entry');
|
entry.classList.add('entry');
|
||||||
|
|
||||||
if ("dataCollectionRegular" in collection.dataset) {
|
if ("collectionRegular" in collection.dataset) {
|
||||||
initializeRemove(collection, entry);
|
initializeRemove(collection, entry);
|
||||||
if (empty_explain !== null) {
|
if (empty_explain !== null) {
|
||||||
empty_explain.remove();
|
empty_explain.remove();
|
||||||
|
@@ -159,3 +159,5 @@ document.addEventListener('DOMContentLoaded', function(e) {
|
|||||||
loadDynamicPicker(document)
|
loadDynamicPicker(document)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
window.loadDynamicPicker = loadDynamicPicker;
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ abstract class AbstractSearch implements SearchInterface
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return new \DateTime($string);
|
return new \DateTime($string);
|
||||||
} catch (ParsingException $ex) {
|
} catch (\Exception $ex) {
|
||||||
$exception = new ParsingException('The date is '
|
$exception = new ParsingException('The date is '
|
||||||
.'not parsable', 0, $ex);
|
.'not parsable', 0, $ex);
|
||||||
|
|
||||||
|
@@ -109,11 +109,10 @@ final class AccompanyingCourseController extends \Symfony\Bundle\FrameworkBundle
|
|||||||
'accompanying_period_id' => $accompanyingCourse->getId(),
|
'accompanying_period_id' => $accompanyingCourse->getId(),
|
||||||
'person_id' => $person_id,
|
'person_id' => $person_id,
|
||||||
]))
|
]))
|
||||||
->setMethod('DELETE')
|
|
||||||
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||||
->getForm();
|
->getForm();
|
||||||
|
|
||||||
if (Request::METHOD_DELETE === $request->getMethod()) {
|
if (Request::METHOD_POST === $request->getMethod()) {
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
if ($form->isValid()) {
|
if ($form->isValid()) {
|
||||||
|
@@ -0,0 +1,198 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Entity\Person;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||||
|
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||||
|
use Chill\PersonBundle\Entity\Person;
|
||||||
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||||
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
#[ORM\MappedSuperclass]
|
||||||
|
class AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||||
|
{
|
||||||
|
use TrackCreationTrait;
|
||||||
|
|
||||||
|
use TrackUpdateTrait;
|
||||||
|
|
||||||
|
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
|
||||||
|
#[Groups(['read', 'docgen:read'])]
|
||||||
|
private CommentEmbeddable $comment;
|
||||||
|
|
||||||
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
||||||
|
#[Groups(['read', 'docgen:read'])]
|
||||||
|
private ?string $freeText = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: PersonResourceKind::class, inversedBy: 'personResources')]
|
||||||
|
#[ORM\JoinColumn(nullable: true)]
|
||||||
|
#[Groups(['read', 'docgen:read'])]
|
||||||
|
private ?PersonResourceKind $kind = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: Person::class)]
|
||||||
|
#[ORM\JoinColumn(nullable: true)]
|
||||||
|
#[Groups(['read', 'docgen:read'])]
|
||||||
|
private ?Person $person = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'resources')]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[Groups(['read'])]
|
||||||
|
private ?Person $personOwner = null;
|
||||||
|
|
||||||
|
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'personResources')]
|
||||||
|
#[ORM\JoinColumn(nullable: true)]
|
||||||
|
#[Groups(['read', 'docgen:read'])]
|
||||||
|
private ?ThirdParty $thirdParty = null;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->comment = new CommentEmbeddable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComment(): CommentEmbeddable
|
||||||
|
{
|
||||||
|
return $this->comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFreeText(): ?string
|
||||||
|
{
|
||||||
|
return $this->freeText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKind(): ?PersonResourceKind
|
||||||
|
{
|
||||||
|
return $this->kind;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPerson(): ?Person
|
||||||
|
{
|
||||||
|
return $this->person;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPersonOwner(): ?Person
|
||||||
|
{
|
||||||
|
return $this->personOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Groups({"read", "docgen:read"})
|
||||||
|
*/
|
||||||
|
public function getResourceKind(): string
|
||||||
|
{
|
||||||
|
if ($this->getPerson() instanceof Person) {
|
||||||
|
return 'person';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->getThirdParty() instanceof ThirdParty) {
|
||||||
|
return 'thirdparty';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->getFreeText()) {
|
||||||
|
return 'freetext';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getThirdParty(): ?ThirdParty
|
||||||
|
{
|
||||||
|
return $this->thirdParty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setComment(?CommentEmbeddable $comment): self
|
||||||
|
{
|
||||||
|
if (null === $comment) {
|
||||||
|
$this->comment->setComment('');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->comment = $comment;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFreeText(?string $freeText): self
|
||||||
|
{
|
||||||
|
$this->freeText = $freeText;
|
||||||
|
|
||||||
|
if ('' !== $freeText && null !== $freeText) {
|
||||||
|
$this->setPerson(null);
|
||||||
|
$this->setThirdParty(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('' === $freeText) {
|
||||||
|
$this->freeText = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setKind(?PersonResourceKind $kind): self
|
||||||
|
{
|
||||||
|
$this->kind = $kind;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPerson(?Person $person): self
|
||||||
|
{
|
||||||
|
$this->person = $person;
|
||||||
|
|
||||||
|
if (null !== $person) {
|
||||||
|
$this->setFreeText('');
|
||||||
|
$this->setThirdParty(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonOwner(?Person $personOwner): self
|
||||||
|
{
|
||||||
|
$this->personOwner = $personOwner;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setThirdParty(?ThirdParty $thirdParty): self
|
||||||
|
{
|
||||||
|
$this->thirdParty = $thirdParty;
|
||||||
|
|
||||||
|
if (null !== $thirdParty) {
|
||||||
|
$this->setFreeText('');
|
||||||
|
$this->setPerson(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Assert\Callback
|
||||||
|
*/
|
||||||
|
public function validate(ExecutionContextInterface $context, mixed $payload): void
|
||||||
|
{
|
||||||
|
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
||||||
|
$context->buildViolation('You must associate at least one entity')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->person && $this->person === $this->personOwner) {
|
||||||
|
$context->buildViolation('You cannot associate a resource with the same person')
|
||||||
|
->addViolation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -12,206 +12,24 @@ declare(strict_types=1);
|
|||||||
namespace Chill\PersonBundle\Entity\Person;
|
namespace Chill\PersonBundle\Entity\Person;
|
||||||
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
|
||||||
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
|
||||||
use Chill\PersonBundle\Entity\Person;
|
|
||||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
||||||
|
|
||||||
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['personResource' => PersonResource::class])]
|
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['personResource' => PersonResource::class])]
|
||||||
#[ORM\Entity]
|
#[ORM\Entity]
|
||||||
#[ORM\Table(name: 'chill_person_resource')]
|
#[ORM\Table(name: 'chill_person_resource')]
|
||||||
class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
class PersonResource extends AbstractPersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||||
{
|
{
|
||||||
use TrackCreationTrait;
|
|
||||||
|
|
||||||
use TrackUpdateTrait;
|
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
|
|
||||||
private CommentEmbeddable $comment;
|
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: true)]
|
|
||||||
private ?string $freeText = null;
|
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
#[Groups(['read', 'docgen:read'])]
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
#[ORM\ManyToOne(targetEntity: PersonResourceKind::class, inversedBy: 'personResources')]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
private ?PersonResourceKind $kind = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The person which host the owner of this resource.
|
|
||||||
*/
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
#[ORM\ManyToOne(targetEntity: Person::class)]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
private ?Person $person = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The person linked with this resource.
|
|
||||||
*/
|
|
||||||
#[Groups(['read'])]
|
|
||||||
#[ORM\ManyToOne(targetEntity: Person::class, inversedBy: 'resources')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
|
||||||
private ?Person $personOwner = null;
|
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
#[ORM\ManyToOne(targetEntity: ThirdParty::class, inversedBy: 'personResources')]
|
|
||||||
#[ORM\JoinColumn(nullable: true)]
|
|
||||||
private ?ThirdParty $thirdParty = null;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->comment = new CommentEmbeddable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getComment(): CommentEmbeddable
|
|
||||||
{
|
|
||||||
return $this->comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFreeText(): ?string
|
|
||||||
{
|
|
||||||
return $this->freeText;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GETTERS.
|
|
||||||
*/
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKind(): ?PersonResourceKind
|
|
||||||
{
|
|
||||||
return $this->kind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPerson(): ?Person
|
|
||||||
{
|
|
||||||
return $this->person;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPersonOwner(): ?Person
|
|
||||||
{
|
|
||||||
return $this->personOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Groups(['read', 'docgen:read'])]
|
|
||||||
public function getResourceKind(): string
|
|
||||||
{
|
|
||||||
if ($this->getPerson() instanceof Person) {
|
|
||||||
return 'person';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->getThirdParty() instanceof ThirdParty) {
|
|
||||||
return 'thirdparty';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $this->getFreeText()) {
|
|
||||||
return 'freetext';
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getThirdParty(): ?ThirdParty
|
|
||||||
{
|
|
||||||
return $this->thirdParty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setComment(?CommentEmbeddable $comment): self
|
|
||||||
{
|
|
||||||
if (null === $comment) {
|
|
||||||
$this->comment->setComment('');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->comment = $comment;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFreeText(?string $freeText): self
|
|
||||||
{
|
|
||||||
$this->freeText = $freeText;
|
|
||||||
|
|
||||||
if ('' !== $freeText && null !== $freeText) {
|
|
||||||
$this->setPerson(null);
|
|
||||||
$this->setThirdParty(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('' === $freeText) {
|
|
||||||
$this->freeText = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setKind(?PersonResourceKind $kind): self
|
|
||||||
{
|
|
||||||
$this->kind = $kind;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPerson(?Person $person): self
|
|
||||||
{
|
|
||||||
$this->person = $person;
|
|
||||||
|
|
||||||
if (null !== $person) {
|
|
||||||
$this->setFreeText('');
|
|
||||||
$this->setThirdParty(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPersonOwner(?Person $personOwner): self
|
|
||||||
{
|
|
||||||
$this->personOwner = $personOwner;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setThirdParty(?ThirdParty $thirdParty): self
|
|
||||||
{
|
|
||||||
$this->thirdParty = $thirdParty;
|
|
||||||
|
|
||||||
if (null !== $thirdParty) {
|
|
||||||
$this->setFreeText('');
|
|
||||||
$this->setPerson(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Assert\Callback]
|
|
||||||
public function validate(ExecutionContextInterface $context, mixed $payload)
|
|
||||||
{
|
|
||||||
if (null === $this->person && null === $this->thirdParty && (null === $this->freeText || '' === $this->freeText)) {
|
|
||||||
$context->buildViolation('You must associate at least one entity')
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $this->person && $this->person === $this->personOwner) {
|
|
||||||
$context->buildViolation('You cannot associate a resource with the same person')
|
|
||||||
->addViolation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user