src/Entity/Reference/ReferencePropertyConstructionType.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\ReferencePropertyConstructionTypeRepository;
  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-construction-type:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-construction-type: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=ReferencePropertyConstructionTypeRepository::class)
  28.  */
  29. class ReferencePropertyConstructionType
  30. {
  31.     public const TRANSLATION_DOMAIN 'reference_property_construction';
  32.     public const REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL 'reference.construction.type.TRADITIONAL';
  33.     public const REFERENCE_CONSTRUCTION_TYPE_WOOD 'reference.construction.type.WOOD';
  34.     public const REFERENCE_CONSTRUCTION_TYPE_STONES 'reference.construction.type.STONES';
  35.     public const REFERENCE_CONSTRUCTION_TYPE_BRICKS 'reference.construction.type.BRICKS';
  36.     public const CODE_REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL '1';
  37.     public const CODE_REFERENCE_CONSTRUCTION_TYPE_WOOD '2';
  38.     public const CODE_REFERENCE_CONSTRUCTION_TYPE_STONES '3';
  39.     public const CODE_REFERENCE_CONSTRUCTION_TYPE_BRICKS '4';
  40.     public const ALL_REFERENCE_CONSTRUCTION_TYPE = [
  41.         self::REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL,
  42.         self::REFERENCE_CONSTRUCTION_TYPE_WOOD,
  43.         self::REFERENCE_CONSTRUCTION_TYPE_STONES,
  44.         self::REFERENCE_CONSTRUCTION_TYPE_BRICKS
  45.     ];
  46.     public const ALL_CODE_REFERENCE_CONSTRUCTION_TYPE = [
  47.         self::CODE_REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL,
  48.         self::CODE_REFERENCE_CONSTRUCTION_TYPE_WOOD,
  49.         self::CODE_REFERENCE_CONSTRUCTION_TYPE_STONES,
  50.         self::CODE_REFERENCE_CONSTRUCTION_TYPE_BRICKS
  51.     ];
  52.     /**
  53.      * @ORM\Id
  54.      * @ORM\GeneratedValue
  55.      * @ORM\Column(type="integer")
  56.      *
  57.      * @Groups({
  58.      *    "property:read",
  59.      *    "mandate:read",
  60.      *    "transaction-item:read",
  61.      *    "reference-construction-type:read",
  62.      *    "milkiya:read",
  63.      *    "business-indication:item:read"
  64.      * })
  65.      */
  66.     private $id;
  67.     /**
  68.      * @ORM\Column(type="string", length=255)
  69.      *
  70.      * @Groups({
  71.      *    "property:read",
  72.      *    "mandate:read",
  73.      *    "transaction-item:read",
  74.      *    "reference-construction-type:read",
  75.      *    "milkiya:read",
  76.      *    "business-indication:item:read"
  77.      * })
  78.      */
  79.     private ?string $name;
  80.     /**
  81.      * @ORM\Column(type="string", length=255)
  82.      *
  83.      * @Groups({
  84.      *    "property:read",
  85.      *    "mandate:read",
  86.      *    "transaction-item:read",
  87.      *    "reference-construction-type:read",
  88.      *    "milkiya:read",
  89.      *    "business-indication:item:read"
  90.      * })
  91.      */
  92.     private ?string $code;
  93.     /**
  94.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyConstructionType")
  95.      */
  96.     private $properties;
  97.     public function __construct()
  98.     {
  99.         $this->properties = new ArrayCollection();
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getName(): ?string
  106.     {
  107.         return $this->name;
  108.     }
  109.     public function setName(string $name): self
  110.     {
  111.         $this->name $name;
  112.         return $this;
  113.     }
  114.     public function getCode(): ?string
  115.     {
  116.         return $this->code;
  117.     }
  118.     public function setCode(string $code): self
  119.     {
  120.         $this->code $code;
  121.         return $this;
  122.     }
  123.     /**
  124.      * @return Collection|Property[]
  125.      */
  126.     public function getProperties(): Collection
  127.     {
  128.         return $this->properties;
  129.     }
  130.     public function addProperty(Property $property): self
  131.     {
  132.         if (!$this->properties->contains($property)) {
  133.             $this->properties[] = $property;
  134.             $property->setReferencePropertyConstructionType($this);
  135.         }
  136.         return $this;
  137.     }
  138.     public function removeProperty(Property $property): self
  139.     {
  140.         if ($this->properties->removeElement($property)) {
  141.             // set the owning side to null (unless already changed)
  142.             if ($property->getReferencePropertyConstructionType() === $this) {
  143.                 $property->setReferencePropertyConstructionType(null);
  144.             }
  145.         }
  146.         return $this;
  147.     }
  148. }