src/Entity/Reference/ReferencePropertyServiceType.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\ReferencePropertyServiceTypeRepository;
  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-service-type:read"}, "swagger_definition_name"="Read"},
  14.  *     denormalizationContext={"groups"={"reference-property-service-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.  *          "order"={"rank"}
  26.  *     }
  27.  * )
  28.  * @ORM\Entity(repositoryClass=ReferencePropertyServiceTypeRepository::class)
  29.  */
  30. class ReferencePropertyServiceType
  31. {
  32.     public const TRANSLATION_DOMAIN 'reference_property';
  33.     public const REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_BUY 'reference.property.service.type.SEARCH_BUY';
  34.     public const REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_RENT 'reference.property.service.type.SEARCH_RENT';
  35.     public const REFERENCE_PROPERTY_SERVICE_TYPE_SELL 'reference.property.service.type.SELL';
  36.     public const REFERENCE_PROPERTY_SERVICE_TYPE_RENTAL 'reference.property.service.type.RENTAL';
  37.     public const ALL_REFERENCE_SERVICE_SEARCH_TYPE = [
  38.         self::REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_BUY,
  39.         self::REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_RENT
  40.     ];
  41.     public const ALL_REFERENCE_SERVICE_TYPE = [
  42.         self::REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_BUY,
  43.         self::REFERENCE_PROPERTY_SERVICE_TYPE_SEARCH_RENT,
  44.         self::REFERENCE_PROPERTY_SERVICE_TYPE_SELL,
  45.         self::REFERENCE_PROPERTY_SERVICE_TYPE_RENTAL
  46.     ];
  47.     public const REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_BUY '1';
  48.     public const REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_RENT '4';
  49.     public const REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SELL '2';
  50.     public const REFERENCE_CODE_PROPERTY_SERVICE_TYPE_RENTAL '3';
  51.     public const ALL_REFERENCE_CODE_PROPERTY_SEARCH_TYPE = [
  52.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_BUY,
  53.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_RENT
  54.     ];
  55.     public const ALL_REFERENCE_CODE_PROPERTY_TYPE = [
  56.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_BUY,
  57.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SEARCH_RENT,
  58.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_SELL,
  59.         self::REFERENCE_CODE_PROPERTY_SERVICE_TYPE_RENTAL
  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-property-service-type:read",
  71.      *    "milkiya:read",
  72.      *    "business-indication:item:read",
  73.      *    "property-visit:read"
  74.      * })
  75.      */
  76.     private $id;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      *
  80.      * @Groups({
  81.      *    "property:read",
  82.      *    "mandate:read",
  83.      *    "transaction-item:read",
  84.      *    "reference-property-service-type:read",
  85.      *    "milkiya:read",
  86.      *    "business-indication:item:read",
  87.      *    "property-visit:read"
  88.      * })
  89.      *
  90.      */
  91.     private ?string $name;
  92.     /**
  93.      * @ORM\Column(type="string", length=255)
  94.      *
  95.      * @Groups({
  96.      *    "property:read",
  97.      *    "mandate:read",
  98.      *    "transaction-item:read",
  99.      *    "reference-property-service-type:read",
  100.      *    "milkiya:read",
  101.      *    "business-indication:item:read",
  102.      *    "property-visit:read"
  103.      * })
  104.      *
  105.      */
  106.     private ?string $code;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity=Property::class, mappedBy="referenceServiceType")
  109.      */
  110.     private $properties;
  111.     /**
  112.      * @ORM\Column(type="integer", nullable=true)
  113.      *
  114.      * @Groups({
  115.      *    "property:read",
  116.      *    "mandate:read",
  117.      *    "transaction-item:read",
  118.      *    "reference-property-service-type:read",
  119.      *    "milkiya:read",
  120.      *    "business-indication:item:read"
  121.      * })
  122.      */
  123.     private ?int $rank;
  124.     public function __construct()
  125.     {
  126.         $this->properties = new ArrayCollection();
  127.     }
  128.     public function getId(): ?int
  129.     {
  130.         return $this->id;
  131.     }
  132.     public function getName(): ?string
  133.     {
  134.         return $this->name;
  135.     }
  136.     public function setName(string $name): self
  137.     {
  138.         $this->name $name;
  139.         return $this;
  140.     }
  141.     public function getCode(): ?string
  142.     {
  143.         return $this->code;
  144.     }
  145.     public function setCode(string $code): self
  146.     {
  147.         $this->code $code;
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, Property>
  152.      */
  153.     public function getProperties(): Collection
  154.     {
  155.         return $this->properties;
  156.     }
  157.     public function addProperty(Property $property): self
  158.     {
  159.         if (!$this->properties->contains($property)) {
  160.             $this->properties[] = $property;
  161.             $property->setReferenceServiceType($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeProperty(Property $property): self
  166.     {
  167.         // set the owning side to null (unless already changed)
  168.         if ($this->properties->removeElement($property) && $property->getReferenceServiceType() === $this) {
  169.             $property->setReferenceServiceType(null);
  170.         }
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return int|null
  175.      */
  176.     public function getRank(): ?int
  177.     {
  178.         return $this->rank;
  179.     }
  180.     /**
  181.      * @param int|null $rank
  182.      *
  183.      * @return $this
  184.      */
  185.     public function setRank(?int $rank): self
  186.     {
  187.         $this->rank $rank;
  188.         return $this;
  189.     }
  190. }