<?php
namespace App\Entity\Reference;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Property;
use App\Repository\Reference\ReferencePropertyDomainRepository;
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-domain:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"reference-property-domain: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=ReferencePropertyDomainRepository::class)
*/
class ReferencePropertyDomain
{
public const TRANSLATION_DOMAIN = 'reference_property';
public const REFERENCE_PROPERTY_DOMAIN_TYPE_NEW = 'reference.property.domain.type.NEW';
public const REFERENCE_PROPERTY_DOMAIN_TYPE_OLD = 'reference.property.domain.type.OLD';
public const REFERENCE_CODE_PROPERTY_DOMAIN_NEW = '1';
public const REFERENCE_CODE_PROPERTY_DOMAIN_OLD = '2';
public const ALL_REFERENCE_PROPERTY_DOMAIN = [
self::REFERENCE_PROPERTY_DOMAIN_TYPE_NEW,
self::REFERENCE_PROPERTY_DOMAIN_TYPE_OLD,
];
public const ALL_REFERENCE_CODE_PROPERTY_DOMAIN = [
self::REFERENCE_CODE_PROPERTY_DOMAIN_NEW,
self::REFERENCE_CODE_PROPERTY_DOMAIN_OLD,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-domain:read",
* "milkiya:read",
* "business-indication:item:read"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Groups({
* "property:read",
* "mandate:read",
* "transaction-item:read",
* "reference-property-domain: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-property-domain:read",
* "milkiya:read"
* })
*/
private ?string $code;
/**
* @ORM\OneToMany(targetEntity=Property::class, mappedBy="referencePropertyDomain")
*/
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->setReferencePropertyDomain($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->getReferencePropertyDomain() === $this) {
$property->setReferencePropertyDomain(null);
}
}
return $this;
}
}