src/Entity/Reference/ReferencePropertyStatus.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\ReferencePropertyStatusRepository;
  6. use App\Traits\RankTrait;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ApiResource(
  13.  *     security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
  14.  *     normalizationContext={"groups"={"reference-property-status:read"}, "swagger_definition_name"="Read"},
  15.  *     denormalizationContext={"groups"={"reference-property-status:write"}, "swagger_definition_name"="Write"},
  16.  *     itemOperations={
  17.  *          "get"
  18.  *     },
  19.  *     collectionOperations={
  20.  *           "get"
  21.  *     },
  22.  *     attributes={
  23.  *          "pagination_items_per_page"=10,
  24.  *          "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
  25.  *     },
  26.  *     order={"rank"}
  27.  * )
  28.  * @ORM\Entity(repositoryClass=ReferencePropertyStatusRepository::class)
  29.  */
  30. class ReferencePropertyStatus
  31. {
  32.     use RankTrait;
  33.     public const TRANSLATION_DOMAIN 'reference_property_status';
  34.     public const REFERENCE_PROPERTY_STATUS_INVALIDE 'reference.property.status.INVALIDE';
  35.     public const REFERENCE_PROPERTY_STATUS_PENDING 'reference.property.status.PENDING';
  36.     public const REFERENCE_PROPERTY_STATUS_IN_PROGRESS 'reference.property.status.IN_PROGRESS';
  37.     public const REFERENCE_PROPERTY_STATUS_RESERVED 'reference.property.status.RESERVED';
  38.     public const REFERENCE_PROPERTY_STATUS_UNDER_COMPROMISE 'reference.property.status.UNDER_COMPROMISE';
  39.     public const REFERENCE_PROPERTY_STATUS_SOLD_BY_MILKIYA 'reference.property.status.SOLD_BY_MILKIYA';
  40.     public const REFERENCE_PROPERTY_STATUS_RENTED_BY_MILKIYA 'reference.property.status.RENTED_BY_MILKIYA';
  41.     public const REFERENCE_PROPERTY_STATUS_SOLD_BY_COMPETITION 'reference.property.status.SOLD_BY_COMPETITION';
  42.     public const REFERENCE_PROPERTY_STATUS_ARCHIVED 'reference.property.status.ARCHIVED';
  43.     public const REFERENCE_CODE_PROPERTY_STATUS_INVALIDE '-1';
  44.     public const REFERENCE_CODE_PROPERTY_STATUS_PENDING '-2';
  45.     public const REFERENCE_CODE_PROPERTY_STATUS_IN_PROGRESS '0';
  46.     public const REFERENCE_CODE_PROPERTY_STATUS_RESERVED '5';
  47.     public const REFERENCE_CODE_PROPERTY_STATUS_UNDER_COMPROMISE '1';
  48.     public const REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_MILKIYA '2';
  49.     public const REFERENCE_CODE_PROPERTY_STATUS_RENTED_BY_MILKIYA '10';
  50.     public const REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_COMPETITION '3';
  51.     public const REFERENCE_CODE_PROPERTY_STATUS_ARCHIVED '4';
  52.     public const ALL_REFERENCE_PROPERTY_STATUS = [
  53.         self::REFERENCE_PROPERTY_STATUS_INVALIDE,
  54.         self::REFERENCE_PROPERTY_STATUS_PENDING,
  55.         self::REFERENCE_PROPERTY_STATUS_IN_PROGRESS,
  56.         self::REFERENCE_PROPERTY_STATUS_RESERVED,
  57.         self::REFERENCE_PROPERTY_STATUS_UNDER_COMPROMISE,
  58.         self::REFERENCE_PROPERTY_STATUS_SOLD_BY_MILKIYA,
  59.         self::REFERENCE_PROPERTY_STATUS_SOLD_BY_COMPETITION,
  60.         self::REFERENCE_PROPERTY_STATUS_ARCHIVED,
  61.         self::REFERENCE_PROPERTY_STATUS_RENTED_BY_MILKIYA
  62.     ];
  63.     public const ALL_REFERENCE_CODE_PROPERTY_STATUS = [
  64.         self::REFERENCE_CODE_PROPERTY_STATUS_INVALIDE,
  65.         self::REFERENCE_CODE_PROPERTY_STATUS_PENDING,
  66.         self::REFERENCE_CODE_PROPERTY_STATUS_IN_PROGRESS,
  67.         self::REFERENCE_CODE_PROPERTY_STATUS_RESERVED,
  68.         self::REFERENCE_CODE_PROPERTY_STATUS_UNDER_COMPROMISE,
  69.         self::REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_MILKIYA,
  70.         self::REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_COMPETITION,
  71.         self::REFERENCE_CODE_PROPERTY_STATUS_ARCHIVED,
  72.         self::REFERENCE_CODE_PROPERTY_STATUS_RENTED_BY_MILKIYA
  73.     ];
  74.     /**
  75.      * @ORM\Id
  76.      * @ORM\GeneratedValue
  77.      * @ORM\Column(type="integer")
  78.      *
  79.      * @Groups({
  80.      *    "property:read",
  81.      *    "mandate:read",
  82.      *    "transaction-item:read",
  83.      *    "reference-property-status:read",
  84.      *    "milkiya:read"
  85.      * })
  86.      */
  87.     private $id;
  88.     /**
  89.      * @ORM\Column(type="string", length=255)
  90.      *
  91.      * @Groups({
  92.      *    "property:read",
  93.      *    "mandate:read",
  94.      *    "transaction-item:read",
  95.      *   "reference-property-status:read",
  96.      *    "milkiya:read"
  97.      * })
  98.      */
  99.     private ?string $name;
  100.     /**
  101.      * @ORM\Column(type="string", length=255)
  102.      *
  103.      * @Groups({
  104.      *    "property:read",
  105.      *    "mandate:read",
  106.      *    "transaction-item:read",
  107.      *    "reference-property-status:read",
  108.      *    "milkiya:read"
  109.      * })
  110.      */
  111.     private ?string $code;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyStatus")
  114.      */
  115.     private $properties;
  116.     public function __construct()
  117.     {
  118.         $this->properties = new ArrayCollection();
  119.     }
  120.     public function getId(): ?int
  121.     {
  122.         return $this->id;
  123.     }
  124.     public function getName(): ?string
  125.     {
  126.         return $this->name;
  127.     }
  128.     public function setName(string $name): self
  129.     {
  130.         $this->name $name;
  131.         return $this;
  132.     }
  133.     public function getCode(): ?string
  134.     {
  135.         return $this->code;
  136.     }
  137.     public function setCode(string $code): self
  138.     {
  139.         $this->code $code;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection|Property[]
  144.      */
  145.     public function getProperties(): Collection
  146.     {
  147.         return $this->properties;
  148.     }
  149.     public function addProperty(Property $property): self
  150.     {
  151.         if (!$this->properties->contains($property)) {
  152.             $this->properties[] = $property;
  153.             $property->setReferencePropertyStatus($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeProperty(Property $property): self
  158.     {
  159.         if ($this->properties->removeElement($property)) {
  160.             // set the owning side to null (unless already changed)
  161.             if ($property->getReferencePropertyStatus() === $this) {
  162.                 $property->setReferencePropertyStatus(null);
  163.             }
  164.         }
  165.         return $this;
  166.     }
  167. }