src/Entity/Reference/ReferencePropertyDomain.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Reference;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Entity\Property;
  5. use App\Repository\Reference\ReferencePropertyDomainRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. /**
  11.  * @ApiResource(
  12.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  13.  *     normalizationContext={"groups"={"reference-property-domain:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-property-domain:write"}, "swagger_definition_name"="Write"},
  15.  *     itemOperations={
  16.  *          "get"
  17.  *     },
  18.  *     collectionOperations={
  19.  *           "get",
  20.  *
  21.  *     },
  22.  *     attributes={
  23.  *          "pagination_items_per_page"=10,
  24.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  25.  *     }
  26.  * )
  27.  * @ORM\Entity(repositoryClass=ReferencePropertyDomainRepository::class)
  28.  */
  29. class ReferencePropertyDomain
  30. {
  31.     public const TRANSLATION_DOMAIN 'reference_property';
  32.     public const REFERENCE_PROPERTY_DOMAIN_TYPE_NEW 'reference.property.domain.type.NEW';
  33.     public const REFERENCE_PROPERTY_DOMAIN_TYPE_OLD 'reference.property.domain.type.OLD';
  34.     public const REFERENCE_CODE_PROPERTY_DOMAIN_NEW '1';
  35.     public const REFERENCE_CODE_PROPERTY_DOMAIN_OLD '2';
  36.     public const ALL_REFERENCE_PROPERTY_DOMAIN = [
  37.         self::REFERENCE_PROPERTY_DOMAIN_TYPE_NEW,
  38.         self::REFERENCE_PROPERTY_DOMAIN_TYPE_OLD,
  39.     ];
  40.     public const ALL_REFERENCE_CODE_PROPERTY_DOMAIN = [
  41.         self::REFERENCE_CODE_PROPERTY_DOMAIN_NEW,
  42.         self::REFERENCE_CODE_PROPERTY_DOMAIN_OLD,
  43.     ];
  44.     /**
  45.      * @ORM\Id
  46.      * @ORM\GeneratedValue
  47.      * @ORM\Column(type="integer")
  48.      *
  49.      * @Groups({
  50.      *    "property:read",
  51.      *    "mandate:read",
  52.      *    "transaction-item:read",
  53.      *    "reference-property-domain:read",
  54.      *    "milkiya:read",
  55.      *    "business-indication:item:read"
  56.      * })
  57.      */
  58.     private $id;
  59.     /**
  60.      * @ORM\Column(type="string", length=255)
  61.      *
  62.      * @Groups({
  63.      *    "property:read",
  64.      *    "mandate:read",
  65.      *    "transaction-item:read",
  66.      *    "reference-property-domain:read",
  67.      *    "milkiya:read",
  68.      *    "business-indication:item:read"
  69.      * })
  70.      */
  71.     private ?string $name;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      *
  75.      * @Groups({
  76.      *    "property:read",
  77.      *    "mandate:read",
  78.      *    "transaction-item:read",
  79.      *    "reference-property-domain:read",
  80.      *    "milkiya:read"
  81.      * })
  82.      */
  83.     private ?string $code;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyDomain")
  86.      */
  87.     private $properties;
  88.     public function __construct()
  89.     {
  90.         $this->properties = new ArrayCollection();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getName(): ?string
  97.     {
  98.         return $this->name;
  99.     }
  100.     public function setName(string $name): self
  101.     {
  102.         $this->name $name;
  103.         return $this;
  104.     }
  105.     public function getCode(): ?string
  106.     {
  107.         return $this->code;
  108.     }
  109.     public function setCode(string $code): self
  110.     {
  111.         $this->code $code;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Property>
  116.      */
  117.     public function getProperties(): Collection
  118.     {
  119.         return $this->properties;
  120.     }
  121.     public function addProperty(Property $property): self
  122.     {
  123.         if (!$this->properties->contains($property)) {
  124.             $this->properties[] = $property;
  125.             $property->setReferencePropertyDomain($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeProperty(Property $property): self
  130.     {
  131.         if ($this->properties->removeElement($property)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($property->getReferencePropertyDomain() === $this) {
  134.                 $property->setReferencePropertyDomain(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139. }