vendor/crosiersource/crosierlib-radx/src/Entity/Fiscal/NotaFiscalEvento.php line 50

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibRadxBundle\Entity\Fiscal;
  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\Entity\EntityId;
  11. use CrosierSource\CrosierLibBaseBundle\Entity\EntityIdTrait;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use SimpleXMLElement;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. /**
  16.  * @ApiResource(
  17.  *     normalizationContext={"groups"={"notaFiscalEvento","entityId"},"enable_max_depth"=true},
  18.  *     denormalizationContext={"groups"={"notaFiscalEvento"},"enable_max_depth"=true},
  19.  *
  20.  *     itemOperations={
  21.  *          "get"={"path"="/fis/notaFiscalEvento/{id}", "security"="is_granted('ROLE_FISCAL')"},
  22.  *          "put"={"path"="/fis/notaFiscalEvento/{id}", "security"="is_granted('ROLE_FISCAL')"},
  23.  *          "delete"={"path"="/fis/notaFiscalEvento/{id}", "security"="is_granted('ROLE_ADMIN')"}
  24.  *     },
  25.  *     collectionOperations={
  26.  *          "get"={"path"="/fis/notaFiscalEvento", "security"="is_granted('ROLE_FISCAL')"},
  27.  *          "post"={"path"="/fis/notaFiscalEvento", "security"="is_granted('ROLE_FISCAL')"}
  28.  *     },
  29.  *
  30.  *     attributes={
  31.  *          "pagination_items_per_page"=10,
  32.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  33.  *     }
  34.  * )
  35.  * @ApiFilter(PropertyFilter::class)
  36.  *
  37.  * @ApiFilter(SearchFilter::class, properties={"nome": "partial", "documento": "exact", "id": "exact"})
  38.  * @ApiFilter(OrderFilter::class, properties={"id", "documento", "nome", "updated"}, arguments={"orderParameterName"="order"})
  39.  *
  40.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Fiscal\NotaFiscalEventoEntityHandler")
  41.  *
  42.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\Fiscal\NotaFiscalEventoRepository")
  43.  * @ORM\Table(name="fis_nf_evento")
  44.  *
  45.  * @author Carlos Eduardo Pauluk
  46.  */
  47. class NotaFiscalEvento implements EntityId
  48. {
  49.     use EntityIdTrait;
  50.     /**
  51.      *
  52.      * @ORM\ManyToOne(targetEntity="CrosierSource\CrosierLibRadxBundle\Entity\Fiscal\NotaFiscal", inversedBy="eventos")
  53.      * @ORM\JoinColumn(name="nota_fiscal_id", nullable=true)
  54.      *
  55.      * @var $notaFiscal null|NotaFiscal
  56.      */
  57.     public ?NotaFiscal $notaFiscal null;
  58.     /**
  59.      *
  60.      * @ORM\Column(name="tp_evento", type="integer", nullable=false)
  61.      * @var null|int
  62.      *
  63.      * @Groups("notaFiscalEvento")
  64.      */
  65.     public ?int $tpEvento null;
  66.     /**
  67.      *
  68.      * @ORM\Column(name="nseq_evento", type="integer", nullable=true)
  69.      * @var null|int
  70.      * @Groups("notaFiscalEvento")
  71.      */
  72.     public ?int $nSeqEvento null;
  73.     /**
  74.      *
  75.      * @ORM\Column(name="desc_evento", type="string", length=200, nullable=false)
  76.      * @var null|string
  77.      *
  78.      * @Groups("notaFiscalEvento")
  79.      */
  80.     public ?string $descEvento null;
  81.     /**
  82.      *
  83.      * @ORM\Column(name="xml", type="string", nullable=true)
  84.      * @var null|string
  85.      *
  86.      * @NotUppercase()
  87.      */
  88.     public ?string $xml null;
  89.     
  90.     /**
  91.      * @return string|null
  92.      */
  93.     public function getXml(): ?string
  94.     {
  95.         return $this->xml;
  96.     }
  97.     /**
  98.      * @param string|null $xml
  99.      * @return NotaFiscalEvento
  100.      */
  101.     public function setXml(?string $xml): NotaFiscalEvento
  102.     {
  103.         $this->xml $xml;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return SimpleXMLElement|null
  108.      */
  109.     public function getXMLDecoded(): ?SimpleXMLElement
  110.     {
  111.         if ($this->getXml()) {
  112.             $xmlUnzip gzdecode(base64_decode($this->getXml()));
  113.             return simplexml_load_string($xmlUnzip);
  114.         }
  115.         return null;
  116.     }
  117. }