<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Reference\ReferencePropertyContractTypeRepository;
use App\Entity\Property;
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-contract-type:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-contract-type:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get"
* },
* collectionOperations={
* "get",
* "milkiya_reference_property_contract_types"={
* "security"="is_granted('PUBLIC_ACCESS')",
* "normalization_context"={"groups"={"milkiya:read"}},
* "method"="GET",
* "path"="/internal/reference_property_contract_types",
* "pagination_enabled" = false
* },
*
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
* @ORM\Entity(repositoryClass=ReferencePropertyContractTypeRepository::class)
*/
class ReferencePropertyContractType
{
public const TRANSLATION_DOMAIN = 'reference_property_contract_type';
public const REFERENCE_PROPERTY_CONTRACT_OFFICE = 'reference.property.contract.OFFICE';
public const REFERENCE_PROPERTY_CONTRACT_WAREHOUSE = 'reference.property.contract.WAREHOUSE';
public const REFERENCE_PROPERTY_CONTRACT_GOODWILL = 'reference.property.contract.GOODWILL';
public const REFERENCE_PROPERTY_CONTRACT_WALLS = 'reference.property.contract.WALLS';
public const CODE_REFERENCE_PROPERTY_CONTRACT_OFFICE = 0;
public const CODE_REFERENCE_PROPERTY_CONTRACT_WAREHOUSE = 1;
public const REFERENCE_CODE_PROPERTY_CONTRACT_GOODWILL = 2;
public const REFERENCE_CODE_PROPERTY_CONTRACT_WALLS = 3;
public const ALL_REFERENCE_PROPERTY_CONTRACT_TYPE = [
self::REFERENCE_PROPERTY_CONTRACT_OFFICE,
self::REFERENCE_PROPERTY_CONTRACT_WAREHOUSE,
self::REFERENCE_PROPERTY_CONTRACT_GOODWILL,
self::REFERENCE_PROPERTY_CONTRACT_WALLS,
];
public const ALL_REFERENCE_CODE_PROPERTY_CONTRACT_TYPE = [
self::CODE_REFERENCE_PROPERTY_CONTRACT_OFFICE,
self::CODE_REFERENCE_PROPERTY_CONTRACT_WAREHOUSE,
self::REFERENCE_CODE_PROPERTY_CONTRACT_GOODWILL,
self::REFERENCE_CODE_PROPERTY_CONTRACT_WALLS,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-contract-type:read",
* "milkiya:read",
* "business-indication:item:read",
* "property-visit:read",
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-contract-type:read",
* "milkiya:read",
* "business-indication:item:read",
* "property-visit:read",
* })
*/
private ?string $name;
/**
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-contract-type:read",
* "milkiya:read",
* "property-visit:read",
* })
*
*/
private ?int $code;
/**
* @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyContractType")
*/
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(): ?int
{
return $this->code;
}
public function setCode(int $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->setReferencePropertyContractType($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->getReferencePropertyContractType() === $this) {
$property->setReferencePropertyContractType(null);
}
}
return $this;
}
public function isOffice(): bool
{
if (null === $this) {
return false;
}
return $this->code === self::CODE_REFERENCE_PROPERTY_CONTRACT_OFFICE;
}
public function isWareHouse(): bool
{
if (null === $this) {
return false;
}
return $this->code === self::CODE_REFERENCE_PROPERTY_CONTRACT_WAREHOUSE;
}
public function isWalls(): bool
{
if (null === $this) {
return false;
}
return $this->code === self::REFERENCE_CODE_PROPERTY_CONTRACT_WALLS;
}
public function isGoodWill(): bool
{
if (null === $this) {
return false;
}
return $this->code === self::REFERENCE_CODE_PROPERTY_CONTRACT_GOODWILL;
}
}