<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Property;
use App\Repository\Reference\ReferencePropertyConstructionTypeRepository;
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-construction-type:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-construction-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=ReferencePropertyConstructionTypeRepository::class)
*/
class ReferencePropertyConstructionType
{
public const TRANSLATION_DOMAIN = 'reference_property_construction';
public const REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL = 'reference.construction.type.TRADITIONAL';
public const REFERENCE_CONSTRUCTION_TYPE_WOOD = 'reference.construction.type.WOOD';
public const REFERENCE_CONSTRUCTION_TYPE_STONES = 'reference.construction.type.STONES';
public const REFERENCE_CONSTRUCTION_TYPE_BRICKS = 'reference.construction.type.BRICKS';
public const CODE_REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL = '1';
public const CODE_REFERENCE_CONSTRUCTION_TYPE_WOOD = '2';
public const CODE_REFERENCE_CONSTRUCTION_TYPE_STONES = '3';
public const CODE_REFERENCE_CONSTRUCTION_TYPE_BRICKS = '4';
public const ALL_REFERENCE_CONSTRUCTION_TYPE = [
self::REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL,
self::REFERENCE_CONSTRUCTION_TYPE_WOOD,
self::REFERENCE_CONSTRUCTION_TYPE_STONES,
self::REFERENCE_CONSTRUCTION_TYPE_BRICKS
];
public const ALL_CODE_REFERENCE_CONSTRUCTION_TYPE = [
self::CODE_REFERENCE_CONSTRUCTION_TYPE_TRADITIONAL,
self::CODE_REFERENCE_CONSTRUCTION_TYPE_WOOD,
self::CODE_REFERENCE_CONSTRUCTION_TYPE_STONES,
self::CODE_REFERENCE_CONSTRUCTION_TYPE_BRICKS
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-construction-type:read",
* "milkiya:read",
* "business-indication:item:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-construction-type:read",
* "milkiya:read",
* "business-indication:item:read"
* })
*/
private ?string $name;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-construction-type:read",
* "milkiya:read",
* "business-indication:item:read"
* })
*/
private ?string $code;
/**
* @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyConstructionType")
*/
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->setReferencePropertyConstructionType($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->getReferencePropertyConstructionType() === $this) {
$property->setReferencePropertyConstructionType(null);
}
}
return $this;
}
}