vendor/crosiersource/crosierlib-radx/src/Entity/Estoque/Subgrupo.php line 57

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\ORM\Mapping as ORM;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Serializer\Annotation\MaxDepth;
  16. /**
  17.  * @ApiResource(
  18.  *     normalizationContext={"groups"={"subgrupo","entityId"},"enable_max_depth"=true},
  19.  *     denormalizationContext={"groups"={"subgrupo"},"enable_max_depth"=true},
  20.  *
  21.  *     itemOperations={
  22.  *          "get"={"path"="/est/subgrupo/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  23.  *          "put"={"path"="/est/subgrupo/{id}", "security"="is_granted('ROLE_ESTOQUE')"},
  24.  *          "delete"={"path"="/est/subgrupo/{id}", "security"="is_granted('ROLE_ADMIN')"}
  25.  *     },
  26.  *     collectionOperations={
  27.  *          "get"={"path"="/est/subgrupo", "security"="is_granted('ROLE_ESTOQUE')"},
  28.  *          "post"={"path"="/est/subgrupo", "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={
  39.  *     "nome": "partial", 
  40.  *     "grupo": "exact", 
  41.  *     "codigo": "exact", 
  42.  *     "id": "exact"
  43.  * })
  44.  * @ApiFilter(OrderFilter::class, properties={"id", "codigo", "nome", "updated"}, arguments={"orderParameterName"="order"})
  45.  *
  46.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Estoque\SubgrupoEntityHandler")
  47.  *
  48.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Estoque\SubgrupoRepository")
  49.  * @ORM\Table(name="est_subgrupo")
  50.  * @TrackedEntity
  51.  *
  52.  * @author Carlos Eduardo Pauluk
  53.  */
  54. class Subgrupo implements EntityId
  55. {
  56.     use EntityIdTrait;
  57.     /**
  58.      * @ORM\Column(name="uuid", type="string", nullable=false, length=36)
  59.      * @NotUppercase()
  60.      * @Groups("subgrupo")
  61.      *
  62.      * @var string|null
  63.      */
  64.     public ?string $UUID null;
  65.     /**
  66.      *
  67.      * @ORM\Column(name="codigo", type="string", nullable=false)
  68.      * @NotUppercase()
  69.      * @Groups("subgrupo")
  70.      *
  71.      * @var string|null
  72.      */
  73.     public ?string $codigo null;
  74.     /**
  75.      *
  76.      * @ORM\Column(name="nome", type="string", nullable=false)
  77.      * @Groups("subgrupo")
  78.      * @NotUppercase()
  79.      *
  80.      * @var string|null
  81.      */
  82.     public ?string $nome null;
  83.     /**
  84.      * Transient.
  85.      * @Groups("subgrupo")
  86.      * @var string|null
  87.      */
  88.     public ?string $descricaoMontada null;
  89.     /**
  90.      *
  91.      * @ORM\ManyToOne(targetEntity="CrosierSource\CrosierLibRadxBundle\Entity\Estoque\Grupo")
  92.      * @ORM\JoinColumn(name="grupo_id", nullable=false)
  93.      * @Groups("subgrupo")
  94.      * @MaxDepth(1)
  95.      * @var $grupo null|Grupo
  96.      */
  97.     public ?Grupo $grupo null;
  98.     /**
  99.      *
  100.      * @ORM\Column(name="json_data", type="json")
  101.      * @var null|array
  102.      * @NotUppercase()
  103.      * @Groups("subgrupo")
  104.      */
  105.     public ?array $jsonData null;
  106.     /**
  107.      * @return string|null
  108.      * @Groups("subgrupo")
  109.      */
  110.     public function getDescricaoMontada(): ?string
  111.     {
  112.         return $this->codigo ' - ' $this->nome;
  113.     }
  114.     
  115.     public function __toString()
  116.     {
  117.         return $this->getId() . ' (' $this->getDescricaoMontada() . ')';
  118.     }
  119. }