<?php
namespace App\Containers\CrmSection\ContractContainer\Entities;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Post;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\DBAL\Types\Types;
use App\Ship\Entities\CommentEntity;
use App\Containers\CrmSection\ContractContainer\Data\Repositories\ContractCommentRepository;
#[ApiResource(
routePrefix: '/crm',
security: "is_granted('ROLE_ADMIN') or is_granted('ROLE_READONLY')",
operations: [
// new GetCollection(
// uriTemplate: '/comments',
// openapiContext: [
// "summary" => ""
// ]
// ),
// new Get(
// uriTemplate: '/comment/{id}',
// openapiContext: [
// "summary" => ""
// ]
// ),
new Post(
uriTemplate: '/contract/comment',
openapiContext: [
"summary" => ""
]
),
// new Patch(
// uriTemplate: '/comment/{id}',
// openapiContext: [
// "summary" => ""
// ]
// ),
// new Put(
// uriTemplate: '/comment/{id}',
// openapiContext: [
// "summary" => ""
// ]
// ),
// new Delete(
// uriTemplate: '/comment/{id}',
// openapiContext: [
// "summary" => ""
// ]
// )
],
normalizationContext: ['groups' => ['read']],
shortName: 'CRM_Contracts'
)]
#[ApiResource(
uriTemplate: '/crm/contract/{contractId}/comment',
uriVariables: [
'contractId' => new Link(fromClass: ContractEntity::class, toProperty: 'entity', identifiers:['id']),
],
operations: [ new GetCollection() ],
security: "is_granted('ROLE_ADMIN')",
shortName: 'CRM_Contracts',
normalizationContext: ['groups' => ['read'], 'enable_max_depth' => true]
)]
#[ApiFilter(OrderFilter::class)]
#[ORM\Entity(repositoryClass: ContractCommentRepository::class)]
class ContractCommentEntity extends CommentEntity
{
#[ORM\ManyToOne(targetEntity: ContractEntity::class)]
#[ORM\JoinColumn(name: 'entity', referencedColumnName: 'id')]
#[Groups(['read'])]
private ContractEntity|null $entity = null;
/**
* Get the value of entity
*/
public function getEntity(): ?ContractEntity
{
return $this->entity;
}
/**
* Set the value of entity
*/
public function setEntity(?ContractEntity $entity): self
{
$this->entity = $entity;
return $this;
}
}