mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
ease docgen normlisation for resources
This commit is contained in:
@@ -19,7 +19,7 @@ use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
@@ -27,7 +27,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_person_resource")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* @Serializer\DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "personResource": personResource::class
|
||||
* })
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
|
||||
/**
|
||||
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
|
||||
* @Groups({"read", "docgen:read"})
|
||||
* @Serializer\Groups({"read", "docgen:read"})
|
||||
*/
|
||||
private CommentEmbeddable $comment;
|
||||
|
||||
@@ -67,7 +67,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* The person which host the owner of this resource.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="personResources")
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\JoinColumn(nullable=true)
|
||||
* @Groups({"read", "docgen:read"})
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* The person linked with this resource.
|
||||
*
|
||||
* @ORM\ManyToOne(targetEntity=Person::class)
|
||||
* @ORM\ManyToOne(targetEntity=Person::class, inversedBy="resources")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
@@ -230,5 +230,10 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
$context->buildViolation('You must associate at least one entity')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if ($this->person === $this->personOwner) {
|
||||
$context->buildViolation('You cannot associate a resource with the same person')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user