vendor/crosiersource/crosierlib-radx/src/Entity/Estoque/Depto.php line 52

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibRadxBundle\Entity\Estoque;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
  8. use CrosierSource\CrosierLibBaseBundle\Doctrine\Annotations\EntityHandler;
  9. use CrosierSource\CrosierLibBaseBundle\Doctrine\Annotations\NotUppercase;
  10. use CrosierSource\CrosierLibBaseBundle\Doctrine\Annotations\TrackedEntity;
  11. use CrosierSource\CrosierLibBaseBundle\Entity\EntityId;
  12. use CrosierSource\CrosierLibBaseBundle\Entity\EntityIdTrait;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. /**
  17.  * @ApiResource(
  18.  *     normalizationContext={"groups"={"depto","entityId"},"enable_max_depth"=true},
  19.  *     denormalizationContext={"groups"={"depto"},"enable_max_depth"=true},
  20.  *
  21.  *     itemOperations={
  22.  *          "get"={"path"="/est/depto/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  23.  *          "put"={"path"="/est/depto/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  24.  *          "delete"={"path"="/est/depto/{id}", "security"="is_granted('ROLE_ADMIN')"}
  25.  *     },
  26.  *     collectionOperations={
  27.  *          "get"={"path"="/est/depto", "security"="is_granted('ROLE_ESTOQUE')"},
  28.  *          "post"={"path"="/est/depto", "security"="is_granted('ROLE_ESTOQUE')"}
  29.  *     },
  30.  *
  31.  *     attributes={
  32.  *          "pagination_items_per_page"=10,
  33.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  34.  *     }
  35.  * )
  36.  * @ApiFilter(PropertyFilter::class)
  37.  *
  38.  * @ApiFilter(SearchFilter::class, properties={"nome": "partial", "codigo": "exact", "id": "exact"})
  39.  * @ApiFilter(OrderFilter::class, properties={"id", "codigo", "nome", "updated"}, arguments={"orderParameterName"="order"})
  40.  *
  41.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Estoque\DeptoEntityHandler")
  42.  *
  43.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Estoque\DeptoRepository")
  44.  * @ORM\Table(name="est_depto")
  45.  * @TrackedEntity
  46.  *
  47.  * @author Carlos Eduardo Pauluk
  48.  */
  49. class Depto implements EntityId
  50. {
  51.     use EntityIdTrait;
  52.     /**
  53.      * @ORM\Column(name="uuid", type="string", nullable=false, length=36)
  54.      * @NotUppercase()
  55.      * @Groups("depto")
  56.      *
  57.      * @var string|null
  58.      */
  59.     public ?string $UUID null;
  60.     /**
  61.      *
  62.      * @ORM\Column(name="codigo", type="string", nullable=false)
  63.      * @NotUppercase()
  64.      * @Groups("depto")
  65.      *
  66.      * @var string|null
  67.      */
  68.     public ?string $codigo null;
  69.     /**
  70.      *
  71.      * @ORM\Column(name="nome", type="string", nullable=false)
  72.      * @Groups("depto")
  73.      * @NotUppercase()
  74.      *
  75.      * @var string|null
  76.      */
  77.     public ?string $nome null;
  78.     /**
  79.      *
  80.      * @var Grupo[]|ArrayCollection|null
  81.      *
  82.      * @ORM\OneToMany(
  83.      *      targetEntity="Grupo",
  84.      *      mappedBy="depto",
  85.      *      orphanRemoval=true
  86.      * )
  87.      */
  88.     public $grupos;
  89.     /**
  90.      *
  91.      * @ORM\Column(name="json_data", type="json")
  92.      * @var null|array
  93.      * @NotUppercase()
  94.      * @Groups("depto")
  95.      */
  96.     public ?array $jsonData null;
  97.     public function __construct()
  98.     {
  99.         $this->grupos = new ArrayCollection();
  100.     }
  101.     /**
  102.      * @return string|null
  103.      * @Groups("depto")
  104.      */
  105.     public function getDescricaoMontada(): ?string
  106.     {
  107.         return $this->codigo ' - ' $this->nome;
  108.     }
  109.     public function __toString()
  110.     {
  111.         return $this->getId() . ' (' $this->getDescricaoMontada() . ')';
  112.     }
  113. }