vendor/crosiersource/crosierlib-radx/src/Entity/Financeiro/Cadeia.php line 51

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\Serializer\Filter\PropertyFilter;
  6. use CrosierSource\CrosierLibBaseBundle\Doctrine\Annotations\EntityHandler;
  7. use CrosierSource\CrosierLibBaseBundle\Entity\EntityId;
  8. use CrosierSource\CrosierLibBaseBundle\Entity\EntityIdTrait;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Entidade 'Cadeia de Movimentações'.
  15.  *
  16.  * Movimentações podem ser dependentes umas das outras, formando uma cadeia de entradas e saídas entre carteiras.
  17.  *
  18.  * @ApiResource(
  19.  *     normalizationContext={"groups"={"cadeia","movimentacao","modo","carteira","categoria","entityId"},"enable_max_depth"=true},
  20.  *     denormalizationContext={"groups"={"cadeia"},"enable_max_depth"=true},
  21.  *
  22.  *     itemOperations={
  23.  *          "get"={"path"="/fin/cadeia/{id}", "security"="is_granted('ROLE_FINAN')"},
  24.  *          "put"={"path"="/fin/cadeia/{id}", "security"="is_granted('ROLE_FINAN')"},
  25.  *          "delete"={"path"="/fin/cadeia/{id}", "security"="is_granted('ROLE_FINAN_ADMIN')"}
  26.  *     },
  27.  *     collectionOperations={
  28.  *          "get"={"path"="/fin/cadeia", "security"="is_granted('ROLE_FINAN')"},
  29.  *          "post"={"path"="/fin/cadeia", "security"="is_granted('ROLE_FINAN')"}
  30.  *     },
  31.  *
  32.  *     attributes={
  33.  *          "pagination_items_per_page"=10,
  34.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  35.  *     }
  36.  *
  37.  * )
  38.  * @ApiFilter(PropertyFilter::class)
  39.  *
  40.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\Financeiro\CadeiaEntityHandler")
  41.  *
  42.  * @ORM\Entity()
  43.  * @ORM\Table(name="fin_cadeia")
  44.  *
  45.  * @author Carlos Eduardo Pauluk
  46.  */
  47. class Cadeia implements EntityId
  48. {
  49.     use EntityIdTrait;
  50.     /**
  51.      * Se for vinculante, ao deletar uma movimentação da cadeia todas deverão são deletadas.
  52.      *
  53.      * @ORM\Column(name="vinculante", type="boolean", nullable=false)
  54.      * @Assert\NotNull()
  55.      * @Groups("cadeia")
  56.      */
  57.     public ?bool $vinculante false;
  58.     /**
  59.      * Se for fechada, não é possível incluir outras movimentações na cadeia.
  60.      *
  61.      * @ORM\Column(name="fechada", type="boolean", nullable=false)
  62.      * @Assert\NotNull()
  63.      * @Groups("cadeia")
  64.      */
  65.     public ?bool $fechada false;
  66.     /**
  67.      * @ORM\OneToMany(
  68.      *      targetEntity="Movimentacao",
  69.      *      mappedBy="cadeia",
  70.      *      orphanRemoval=true
  71.      * )
  72.      * @Groups("cadeia")
  73.      * @var Movimentacao[]|ArrayCollection|null
  74.      */
  75.     public $movimentacoes;
  76.     public function __construct()
  77.     {
  78.         $this->movimentacoes = new ArrayCollection();
  79.     }
  80. }