src/Entity/Reference/ReferencePropertyState.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\ReferencePropertyStateRepository;
  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') or is_granted('ROLE_IT') ",
  13.  *     normalizationContext={"groups"={"reference-property-state-type:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-property-state-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=ReferencePropertyStateRepository::class)
  28.  */
  29. class ReferencePropertyState
  30. {
  31.     public const TRANSLATION_DOMAIN 'reference_property';
  32.     public const REFERENCE_PROPERTY_STATE_TYPE_NEW 'reference.property.state.type.NEW';
  33.     public const REFERENCE_PROPERTY_STATE_TYPE_RENOVATE 'reference.property.state.type.RENOVATE';
  34.     public const REFERENCE_PROPERTY_STATE_TYPE_NORMAL 'reference.property.state.type.NORMAL';
  35.     public const REFERENCE_PROPERTY_STATE_TYPE_IN_CONSTRUCTION 'reference.property.state.type.IN_CONSTRUCTION';
  36.     public const REFERENCE_PROPERTY_STATE_TYPE_IN_RUIN 'reference.property.state.type.IN_RUIN';
  37.     public const REFERENCE_PROPERTY_STATE_TYPE_TO_RENOVATE_OLD 'reference.property.state.type.TO_RENOVATE_OLD';
  38.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_NEW '1';
  39.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_RENOVATE '2';
  40.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_NORMAL '3';
  41.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_CONSTRUCTION '4';
  42.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_RUIN '5';
  43.     public const REFERENCE_PROPERTY_STATE_TYPE_CODE_TO_RENOVATE_OLD '6';
  44.     public const ALL_REFERENCE_TYPE = [
  45.         self::REFERENCE_PROPERTY_STATE_TYPE_NEW,
  46.         self::REFERENCE_PROPERTY_STATE_TYPE_RENOVATE,
  47.         self::REFERENCE_PROPERTY_STATE_TYPE_NORMAL,
  48.         self::REFERENCE_PROPERTY_STATE_TYPE_IN_CONSTRUCTION,
  49.         self::REFERENCE_PROPERTY_STATE_TYPE_IN_RUIN,
  50.         self::REFERENCE_PROPERTY_STATE_TYPE_TO_RENOVATE_OLD,
  51.     ];
  52.     public const ALL_STATE_TYPE_CODE = [
  53.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_NEW,
  54.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_RENOVATE,
  55.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_NORMAL,
  56.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_CONSTRUCTION,
  57.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_RUIN,
  58.         self::REFERENCE_PROPERTY_STATE_TYPE_CODE_TO_RENOVATE_OLD
  59.     ];
  60.     /**
  61.      * @ORM\Id
  62.      * @ORM\GeneratedValue
  63.      * @ORM\Column(type="integer")
  64.      *
  65.      * @Groups({
  66.      *    "property:read",
  67.      *    "mandate:read",
  68.      *    "transaction-item:read",
  69.      *    "reference-property-state-type:read",
  70.      *    "business-indication:item:read",
  71.      *    "property-visit:read"
  72.      * })
  73.      */
  74.     private $id;
  75.     /**
  76.      * @ORM\Column(type="string", length=255)
  77.      *
  78.      * @Groups({
  79.      *   "property:read",
  80.      *   "mandate:read",
  81.      *   "transaction-item:read",
  82.      *   "reference-property-state-type:read",
  83.      *   "milkiya:read",
  84.      *   "business-indication:item:read",
  85.      *    "property-visit:read"
  86.      * })
  87.      */
  88.     private ?string $name;
  89.     /**
  90.      * @ORM\Column(type="string", length=255)
  91.      *
  92.      * @Groups({
  93.      *    "property:read",
  94.      *    "mandate:read",
  95.      *    "transaction-item:read",
  96.      *    "reference-property-state-type:read",
  97.      *    "milkiya:read",
  98.      *    "property-visit:read"
  99.      * })
  100.      */
  101.     private ?string $code;
  102.     /**
  103.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="refrencePropertyState")
  104.      */
  105.     private $properties;
  106.     public function __construct()
  107.     {
  108.         $this->properties = new ArrayCollection();
  109.     }
  110.     public function getId(): ?int
  111.     {
  112.         return $this->id;
  113.     }
  114.     public function getName(): ?string
  115.     {
  116.         return $this->name;
  117.     }
  118.     public function setName(string $name): self
  119.     {
  120.         $this->name $name;
  121.         return $this;
  122.     }
  123.     public function getCode(): ?string
  124.     {
  125.         return $this->code;
  126.     }
  127.     public function setCode(string $code): self
  128.     {
  129.         $this->code $code;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, Property>
  134.      */
  135.     public function getProperties(): Collection
  136.     {
  137.         return $this->properties;
  138.     }
  139.     public function addProperty(Property $property): self
  140.     {
  141.         if (!$this->properties->contains($property)) {
  142.             $this->properties[] = $property;
  143.             $property->setRefrencePropertyState($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeProperty(Property $property): self
  148.     {
  149.         if ($this->properties->removeElement($property)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($property->getRefrencePropertyState() === $this) {
  152.                 $property->setRefrencePropertyState(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157. }