vendor/crosiersource/crosierlib-radx/src/Entity/Financeiro/TipoLancto.php line 55

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibRadxBundle\Entity\Financeiro;
  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\Entity\EntityId;
  10. use CrosierSource\CrosierLibBaseBundle\Entity\EntityIdTrait;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14.  * Entidade Tipo de Lançamento.
  15.  *
  16.  * @ApiResource(
  17.  *     normalizationContext={"groups"={"tipoLancto","entityId"},"enable_max_depth"=true},
  18.  *     denormalizationContext={"groups"={"tipoLancto"},"enable_max_depth"=true},
  19.  *
  20.  *     itemOperations={
  21.  *          "get"={"path"="/fin/tipoLancto/{id}", "security"="is_granted('ROLE_FINAN')"},
  22.  *          "put"={"path"="/fin/tipoLancto/{id}", "security"="is_granted('ROLE_FINAN_MASTER')"},
  23.  *          "delete"={"path"="/fin/tipoLancto/{id}", "security"="is_granted('ROLE_FINAN_MASTER')"}
  24.  *     },
  25.  *     collectionOperations={
  26.  *          "get"={"path"="/fin/tipoLancto", "security"="is_granted('ROLE_FINAN')"},
  27.  *          "post"={"path"="/fin/tipoLancto", "security"="is_granted('ROLE_FINAN_MASTER')"}
  28.  *     },
  29.  *
  30.  *     attributes={
  31.  *          "pagination_items_per_page"=10,
  32.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  33.  *     }
  34.  *
  35.  * )
  36.  * @ApiFilter(PropertyFilter::class)
  37.  *
  38.  * @ApiFilter(SearchFilter::class,
  39.  *     properties={
  40.  *     "id": "exact",
  41.  *     "descricao": "partial"
  42.  * })
  43.  * @ApiFilter(OrderFilter::class, properties={"id", "descricao", "dtVencto", "updated"}, arguments={"orderParameterName"="order"})
  44.  *
  45.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Financeiro\TipoLanctoEntityHandler")
  46.  *
  47.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Financeiro\TipoLanctoRepository")
  48.  * @ORM\Table(name="fin_tipo_lancto")
  49.  *
  50.  * @author Carlos Eduardo Pauluk
  51.  */
  52. class TipoLancto implements EntityId
  53. {
  54.     use EntityIdTrait;
  55.     /**
  56.      *
  57.      * @ORM\Column(name="codigo", type="integer", nullable=false)
  58.      * @Groups("tipoLancto")
  59.      *
  60.      * @var int|null
  61.      */
  62.     public ?int $codigo null;
  63.     /**
  64.      *
  65.      * @ORM\Column(name="descricao", type="string", nullable=false, length=40)
  66.      * @Groups("tipoLancto")
  67.      *
  68.      * @var string|null
  69.      */
  70.     public ?string $descricao null;
  71.     /**
  72.      * Transient.
  73.      *
  74.      * @var string|null
  75.      */
  76.     public ?string $descricaoMontada null;
  77.     /**
  78.      * @param bool|null $format
  79.      * @return int|string|null
  80.      */
  81.     public function getCodigo(?bool $format false)
  82.     {
  83.         if ($format) {
  84.             return str_pad($this->codigo2'0'STR_PAD_LEFT);
  85.         }
  86.         return $this->codigo;
  87.     }
  88.     /**
  89.      * @Groups("tipoLancto")
  90.      * @return null|string
  91.      */
  92.     public function getDescricaoMontada(): ?string
  93.     {
  94.         return $this->getCodigo(true) . ' - ' $this->descricao;
  95.     }
  96. }