<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Property;
use App\Repository\Reference\ReferencePropertyStateRepository;
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') or is_granted('ROLE_IT') ",
* normalizationContext={"groups"={"reference-property-state-type:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-property-state-type:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get"
* },
* collectionOperations={
* "get",
*
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
* @ORM\Entity(repositoryClass=ReferencePropertyStateRepository::class)
*/
class ReferencePropertyState
{
public const TRANSLATION_DOMAIN = 'reference_property';
public const REFERENCE_PROPERTY_STATE_TYPE_NEW = 'reference.property.state.type.NEW';
public const REFERENCE_PROPERTY_STATE_TYPE_RENOVATE = 'reference.property.state.type.RENOVATE';
public const REFERENCE_PROPERTY_STATE_TYPE_NORMAL = 'reference.property.state.type.NORMAL';
public const REFERENCE_PROPERTY_STATE_TYPE_IN_CONSTRUCTION = 'reference.property.state.type.IN_CONSTRUCTION';
public const REFERENCE_PROPERTY_STATE_TYPE_IN_RUIN = 'reference.property.state.type.IN_RUIN';
public const REFERENCE_PROPERTY_STATE_TYPE_TO_RENOVATE_OLD = 'reference.property.state.type.TO_RENOVATE_OLD';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_NEW = '1';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_RENOVATE = '2';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_NORMAL = '3';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_CONSTRUCTION = '4';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_RUIN = '5';
public const REFERENCE_PROPERTY_STATE_TYPE_CODE_TO_RENOVATE_OLD = '6';
public const ALL_REFERENCE_TYPE = [
self::REFERENCE_PROPERTY_STATE_TYPE_NEW,
self::REFERENCE_PROPERTY_STATE_TYPE_RENOVATE,
self::REFERENCE_PROPERTY_STATE_TYPE_NORMAL,
self::REFERENCE_PROPERTY_STATE_TYPE_IN_CONSTRUCTION,
self::REFERENCE_PROPERTY_STATE_TYPE_IN_RUIN,
self::REFERENCE_PROPERTY_STATE_TYPE_TO_RENOVATE_OLD,
];
public const ALL_STATE_TYPE_CODE = [
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_NEW,
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_RENOVATE,
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_NORMAL,
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_CONSTRUCTION,
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_IN_RUIN,
self::REFERENCE_PROPERTY_STATE_TYPE_CODE_TO_RENOVATE_OLD
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-state-type:read",
* "business-indication:item:read",
* "property-visit:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-state-type:read",
* "milkiya:read",
* "business-indication:item:read",
* "property-visit:read"
* })
*/
private ?string $name;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-state-type:read",
* "milkiya:read",
* "property-visit:read"
* })
*/
private ?string $code;
/**
* @ORM\OneToMany(targetEntity=Property::class, mappedBy="refrencePropertyState")
*/
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<int, Property>
*/
public function getProperties(): Collection
{
return $this->properties;
}
public function addProperty(Property $property): self
{
if (!$this->properties->contains($property)) {
$this->properties[] = $property;
$property->setRefrencePropertyState($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->getRefrencePropertyState() === $this) {
$property->setRefrencePropertyState(null);
}
}
return $this;
}
}