vendor/crosiersource/crosierlib-radx/src/Entity/Estoque/Grupo.php line 59

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. use Symfony\Component\Serializer\Annotation\MaxDepth;
  17. /**
  18.  * @ApiResource(
  19.  *     shortName="Estoque/Grupo",
  20.  *     normalizationContext={"groups"={"grupo","entityId"},"enable_max_depth"=true},
  21.  *     denormalizationContext={"groups"={"grupo"},"enable_max_depth"=true},
  22.  *
  23.  *     itemOperations={
  24.  *          "get"={"path"="/est/grupo/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  25.  *          "put"={"path"="/est/grupo/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  26.  *          "delete"={"path"="/est/grupo/{id}", "security"="is_granted('ROLE_ADMIN')"}
  27.  *     },
  28.  *     collectionOperations={
  29.  *          "get"={"path"="/est/grupo", "security"="is_granted('ROLE_ESTOQUE')"},
  30.  *          "post"={"path"="/est/grupo", "security"="is_granted('ROLE_ESTOQUE')"}
  31.  *     },
  32.  *
  33.  *     attributes={
  34.  *          "pagination_items_per_page"=10,
  35.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  36.  *     }
  37.  * )
  38.  * @ApiFilter(PropertyFilter::class)
  39.  *
  40.  * @ApiFilter(SearchFilter::class, properties={
  41.  *     "nome": "partial", 
  42.  *     "depto": "exact", 
  43.  *     "codigo": "exact", 
  44.  *     "id": "exact"
  45.  * })
  46.  * @ApiFilter(OrderFilter::class, properties={"id", "codigo", "nome", "updated"}, arguments={"orderParameterName"="order"})
  47.  *
  48.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Estoque\GrupoEntityHandler")
  49.  *
  50.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Estoque\GrupoRepository")
  51.  * @ORM\Table(name="est_grupo")
  52.  * @TrackedEntity
  53.  *
  54.  * @author Carlos Eduardo Pauluk
  55.  */
  56. class Grupo implements EntityId
  57. {
  58.     use EntityIdTrait;
  59.     /**
  60.      * @ORM\Column(name="uuid", type="string", nullable=false, length=36)
  61.      * @NotUppercase()
  62.      * @Groups("grupo")
  63.      *
  64.      * @var string|null
  65.      */
  66.     public ?string $UUID null;
  67.     /**
  68.      *
  69.      * @ORM\Column(name="codigo", type="string", nullable=false)
  70.      * @NotUppercase()
  71.      * @Groups("grupo")
  72.      *
  73.      * @var string|null
  74.      */
  75.     public ?string $codigo null;
  76.     /**
  77.      *
  78.      * @ORM\Column(name="nome", type="string", nullable=false)
  79.      * @Groups("grupo")
  80.      * @NotUppercase()
  81.      *
  82.      * @var string|null
  83.      */
  84.     public ?string $nome null;
  85.     /**
  86.      *
  87.      * @ORM\ManyToOne(targetEntity="CrosierSource\CrosierLibRadxBundle\Entity\Estoque\Depto")
  88.      * @ORM\JoinColumn(name="depto_id", nullable=false)
  89.      * @Groups("grupo")
  90.      * @MaxDepth(1)
  91.      * @var $depto null|Depto
  92.      */
  93.     public ?Depto $depto null;
  94.     /**
  95.      *
  96.      * @var Subgrupo[]|ArrayCollection|null
  97.      *
  98.      * @ORM\OneToMany(
  99.      *      targetEntity="Subgrupo",
  100.      *      mappedBy="grupo",
  101.      *      orphanRemoval=true
  102.      * )
  103.      */
  104.     public $subgrupos;
  105.     /**
  106.      *
  107.      * @ORM\Column(name="json_data", type="json")
  108.      * @var null|array
  109.      * @NotUppercase()
  110.      * @Groups("grupo")
  111.      */
  112.     public ?array $jsonData null;
  113.     public function __construct()
  114.     {
  115.         $this->subgrupos = new ArrayCollection();
  116.     }
  117.     /**
  118.      * @return string|null
  119.      * @Groups("grupo")
  120.      */
  121.     public function getDescricaoMontada(): ?string
  122.     {
  123.         return $this->codigo ' - ' $this->nome;
  124.     }
  125.     public function __toString()
  126.     {
  127.         return $this->getId() . ' (' $this->getDescricaoMontada() . ')';
  128.     }
  129. }