src/Entity/Reference/ReferencePropertyOrientation.php line 33

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\ReferencePropertyOrientationRepository;
  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-orientation-type:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-orientation-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.  *
  28.  * @ORM\Entity(repositoryClass=ReferencePropertyOrientationRepository::class)
  29.  */
  30. class ReferencePropertyOrientation
  31. {
  32.     public const TRANSLATION_DOMAIN 'reference_property';
  33.     public const REFERENCE_PROPERTY_ORIENTATION_EAST 'reference.property.orientation.EAST';
  34.     public const REFERENCE_PROPERTY_ORIENTATION_WEST 'reference.property.orientation.WEST';
  35.     public const REFERENCE_PROPERTY_ORIENTATION_NORTH 'reference.property.orientation.NORTH';
  36.     public const REFERENCE_PROPERTY_ORIENTATION_SOUTH 'reference.property.orientation.SOUTH';
  37.     public const REFERENCE_PROPERTY_ORIENTATION_NORTH_EAST 'reference.property.orientation.NORTH_EAST';
  38.     public const REFERENCE_PROPERTY_ORIENTATION_NORTH_WEST 'reference.property.orientation.NORTH_WEST';
  39.     public const REFERENCE_PROPERTY_ORIENTATION_SOUTH_EAST 'reference.property.orientation.SOUTH_EAST';
  40.     public const REFERENCE_PROPERTY_ORIENTATION_SOUTH_WEST 'reference.property.orientation.SOUTH_WEST';
  41.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_EAST '0';
  42.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_WEST '1';
  43.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_NORTH '2';
  44.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH '3';
  45.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_NORTH_EAST '4';
  46.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_NORTH_WEST '5';
  47.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH_EAST '6';
  48.     public const CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH_WEST '7';
  49.     public const ALL_REFERENCE_PROPERTY_ORIENTATION = [
  50.         self::REFERENCE_PROPERTY_ORIENTATION_EASTself::REFERENCE_PROPERTY_ORIENTATION_WEST,
  51.         self::REFERENCE_PROPERTY_ORIENTATION_NORTHself::REFERENCE_PROPERTY_ORIENTATION_SOUTH,
  52.         self::REFERENCE_PROPERTY_ORIENTATION_NORTH_EASTself::REFERENCE_PROPERTY_ORIENTATION_NORTH_WEST,
  53.         self::REFERENCE_PROPERTY_ORIENTATION_SOUTH_EASTself::REFERENCE_PROPERTY_ORIENTATION_SOUTH_WEST
  54.     ];
  55.     public const ALL_CODE_REFERENCE_PROPERTY_ORIENTATION = [
  56.         self::CODE_REFERENCE_PROPERTY_ORIENTATION_EASTself::CODE_REFERENCE_PROPERTY_ORIENTATION_WEST,
  57.         self::CODE_REFERENCE_PROPERTY_ORIENTATION_NORTHself::CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH,
  58.         self::CODE_REFERENCE_PROPERTY_ORIENTATION_NORTH_EASTself::CODE_REFERENCE_PROPERTY_ORIENTATION_NORTH_WEST,
  59.         self::CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH_EASTself::CODE_REFERENCE_PROPERTY_ORIENTATION_SOUTH_WEST
  60.     ];
  61.     /**
  62.      * @ORM\Id
  63.      * @ORM\GeneratedValue
  64.      * @ORM\Column(type="integer")
  65.      *
  66.      * @Groups({
  67.      *    "property:read",
  68.      *    "mandate:read",
  69.      *    "transaction-item:read",
  70.      *    "reference-orientation-type:read",
  71.      *    "milkiya:read",
  72.      *    "business-indication:item:read"
  73.      * })
  74.      */
  75.     private $id;
  76.     /**
  77.      * @ORM\Column(type="string", length=255)
  78.      *
  79.      * @Groups({
  80.      *    "property:read",
  81.      *    "mandate:read",
  82.      *    "transaction-item:read",
  83.      *    "reference-orientation-type:read",
  84.      *    "milkiya:read"
  85.      * })
  86.      */
  87.     private ?string $name;
  88.     /**
  89.      * @ORM\Column(type="string", length=255)
  90.      *
  91.      * @Groups({
  92.      *    "property:read",
  93.      *    "mandate:read",
  94.      *    "transaction-item:read",
  95.      *    "reference-orientation-type:read",
  96.      *    "milkiya:read"
  97.      * })
  98.      */
  99.     private ?string $code;
  100.     /**
  101.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyOrientationType")
  102.      */
  103.     private $properties;
  104.     public function __construct()
  105.     {
  106.         $this->properties = new ArrayCollection();
  107.     }
  108.     public function getId(): ?int
  109.     {
  110.         return $this->id;
  111.     }
  112.     public function getName(): ?string
  113.     {
  114.         return $this->name;
  115.     }
  116.     public function setName(string $name): self
  117.     {
  118.         $this->name $name;
  119.         return $this;
  120.     }
  121.     public function getCode(): ?string
  122.     {
  123.         return $this->code;
  124.     }
  125.     public function setCode(string $code): self
  126.     {
  127.         $this->code $code;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return Collection|Property[]
  132.      */
  133.     public function getProperties(): Collection
  134.     {
  135.         return $this->properties;
  136.     }
  137.     public function addProperty(Property $property): self
  138.     {
  139.         if (!$this->properties->contains($property)) {
  140.             $this->properties[] = $property;
  141.             $property->setReferencePropertyOrientationType($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeProperty(Property $property): self
  146.     {
  147.         if ($this->properties->removeElement($property)) {
  148.             // set the owning side to null (unless already changed)
  149.             if ($property->getReferencePropertyOrientationType() === $this) {
  150.                 $property->setReferencePropertyOrientationType(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155. }