<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Property;
use App\Repository\Reference\ReferencePropertyStatusRepository;
use App\Traits\RankTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* normalizationContext={"groups"={"reference-property-status:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-property-status:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get"
* },
* collectionOperations={
* "get"
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* },
* order={"rank"}
* )
* @ORM\Entity(repositoryClass=ReferencePropertyStatusRepository::class)
*/
class ReferencePropertyStatus
{
use RankTrait;
public const TRANSLATION_DOMAIN = 'reference_property_status';
public const REFERENCE_PROPERTY_STATUS_INVALIDE = 'reference.property.status.INVALIDE';
public const REFERENCE_PROPERTY_STATUS_PENDING = 'reference.property.status.PENDING';
public const REFERENCE_PROPERTY_STATUS_IN_PROGRESS = 'reference.property.status.IN_PROGRESS';
public const REFERENCE_PROPERTY_STATUS_RESERVED = 'reference.property.status.RESERVED';
public const REFERENCE_PROPERTY_STATUS_UNDER_COMPROMISE = 'reference.property.status.UNDER_COMPROMISE';
public const REFERENCE_PROPERTY_STATUS_SOLD_BY_MILKIYA = 'reference.property.status.SOLD_BY_MILKIYA';
public const REFERENCE_PROPERTY_STATUS_RENTED_BY_MILKIYA = 'reference.property.status.RENTED_BY_MILKIYA';
public const REFERENCE_PROPERTY_STATUS_SOLD_BY_COMPETITION = 'reference.property.status.SOLD_BY_COMPETITION';
public const REFERENCE_PROPERTY_STATUS_ARCHIVED = 'reference.property.status.ARCHIVED';
public const REFERENCE_CODE_PROPERTY_STATUS_INVALIDE = '-1';
public const REFERENCE_CODE_PROPERTY_STATUS_PENDING = '-2';
public const REFERENCE_CODE_PROPERTY_STATUS_IN_PROGRESS = '0';
public const REFERENCE_CODE_PROPERTY_STATUS_RESERVED = '5';
public const REFERENCE_CODE_PROPERTY_STATUS_UNDER_COMPROMISE = '1';
public const REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_MILKIYA = '2';
public const REFERENCE_CODE_PROPERTY_STATUS_RENTED_BY_MILKIYA = '10';
public const REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_COMPETITION = '3';
public const REFERENCE_CODE_PROPERTY_STATUS_ARCHIVED = '4';
public const ALL_REFERENCE_PROPERTY_STATUS = [
self::REFERENCE_PROPERTY_STATUS_INVALIDE,
self::REFERENCE_PROPERTY_STATUS_PENDING,
self::REFERENCE_PROPERTY_STATUS_IN_PROGRESS,
self::REFERENCE_PROPERTY_STATUS_RESERVED,
self::REFERENCE_PROPERTY_STATUS_UNDER_COMPROMISE,
self::REFERENCE_PROPERTY_STATUS_SOLD_BY_MILKIYA,
self::REFERENCE_PROPERTY_STATUS_SOLD_BY_COMPETITION,
self::REFERENCE_PROPERTY_STATUS_ARCHIVED,
self::REFERENCE_PROPERTY_STATUS_RENTED_BY_MILKIYA
];
public const ALL_REFERENCE_CODE_PROPERTY_STATUS = [
self::REFERENCE_CODE_PROPERTY_STATUS_INVALIDE,
self::REFERENCE_CODE_PROPERTY_STATUS_PENDING,
self::REFERENCE_CODE_PROPERTY_STATUS_IN_PROGRESS,
self::REFERENCE_CODE_PROPERTY_STATUS_RESERVED,
self::REFERENCE_CODE_PROPERTY_STATUS_UNDER_COMPROMISE,
self::REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_MILKIYA,
self::REFERENCE_CODE_PROPERTY_STATUS_SOLD_BY_COMPETITION,
self::REFERENCE_CODE_PROPERTY_STATUS_ARCHIVED,
self::REFERENCE_CODE_PROPERTY_STATUS_RENTED_BY_MILKIYA
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-status:read",
* "milkiya:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-status:read",
* "milkiya:read"
* })
*/
private ?string $name;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-status:read",
* "milkiya:read"
* })
*/
private ?string $code;
/**
* @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyStatus")
*/
private $properties;
public function __construct()
{
$this->properties = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
/**
* @return Collection|Property[]
*/
public function getProperties(): Collection
{
return $this->properties;
}
public function addProperty(Property $property): self
{
if (!$this->properties->contains($property)) {
$this->properties[] = $property;
$property->setReferencePropertyStatus($this);
}
return $this;
}
public function removeProperty(Property $property): self
{
if ($this->properties->removeElement($property)) {
// set the owning side to null (unless already changed)
if ($property->getReferencePropertyStatus() === $this) {
$property->setReferencePropertyStatus(null);
}
}
return $this;
}
}