vendor/crosiersource/crosierlib-radx/src/Entity/RH/Colaborador.php line 55

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibRadxBundle\Entity\RH;
  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 DateTime;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Exception;
  15. use Symfony\Component\HttpFoundation\File\File;
  16. use Symfony\Component\HttpFoundation\File\UploadedFile;
  17. use Symfony\Component\Serializer\Annotation\Groups;
  18. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  19. /**
  20.  * @ApiResource(
  21.  *     normalizationContext={"groups"={"colaborador","entityId"},"enable_max_depth"=true},
  22.  *     denormalizationContext={"groups"={"colaborador"},"enable_max_depth"=true},
  23.  *
  24.  *     itemOperations={
  25.  *          "get"={"path"="/rh/colaborador/{id}", "security"="is_granted('ROLE_RH')"},
  26.  *          "put"={"path"="/rh/colaborador/{id}", "security"="is_granted('ROLE_RH')"},
  27.  *          "delete"={"path"="/rh/colaborador/{id}", "security"="is_granted('ROLE_ADMIN')"}
  28.  *     },
  29.  *     collectionOperations={
  30.  *          "get"={"path"="/rh/colaborador", "security"="is_granted('ROLE_RH')"},
  31.  *          "post"={"path"="/rh/colaborador", "security"="is_granted('ROLE_RH')"}
  32.  *     },
  33.  *
  34.  *     attributes={
  35.  *          "pagination_items_per_page"=10,
  36.  *          "formats"={"jsonld", "csv"={"text/csv"}}
  37.  *     }
  38.  * )
  39.  * @ApiFilter(PropertyFilter::class)
  40.  *
  41.  * @ApiFilter(SearchFilter::class, properties={"nome": "partial", "documento": "exact", "id": "exact"})
  42.  * @ApiFilter(OrderFilter::class, properties={"id", "documento", "nome", "updated"}, arguments={"orderParameterName"="order"})
  43.  *
  44.  * @EntityHandler(entityHandlerClass="CrosierSource\CrosierLibRadxBundle\EntityHandler\RH\ColaboradorEntityHandler")
  45.  *
  46.  * @ORM\Entity(repositoryClass="CrosierSource\CrosierLibRadxBundle\Repository\RH\ColaboradorRepository")
  47.  * @ORM\Table(name="rh_colaborador")
  48.  * @Vich\Uploadable()
  49.  *
  50.  * @author Carlos Eduardo Pauluk
  51.  */
  52. class Colaborador implements EntityId
  53. {
  54.     use EntityIdTrait;
  55.     /**
  56.      *
  57.      * @ORM\Column(name="cpf", type="string")
  58.      * @var null|string
  59.      *
  60.      * @Groups("colaborador")
  61.      */
  62.     public ?string $cpf null;
  63.     /**
  64.      *
  65.      * @ORM\Column(name="nome", type="string")
  66.      * @var null|string
  67.      *
  68.      * @Groups("colaborador")
  69.      */
  70.     public ?string $nome null;
  71.     /**
  72.      * Informa se o colaborador está trabalhando atualmente na empresa.
  73.      *
  74.      * @ORM\Column(name="atual", type="boolean")
  75.      * @var null|bool
  76.      *
  77.      * @Groups("colaborador")
  78.      */
  79.     public ?bool $atual null;
  80.     /**
  81.      *
  82.      * @ORM\Column(name="json_data", type="json")
  83.      * @var null|array
  84.      * @NotUppercase()
  85.      * @Groups("colaborador")
  86.      */
  87.     public ?array $jsonData null;
  88.     /**
  89.      * @Vich\UploadableField(mapping="rh_colaborador_foto", fileNameProperty="imageName")
  90.      * @var null|File
  91.      */
  92.     private ?File $imageFile null;
  93.     /**
  94.      * @ORM\Column(name="image_name", type="string")
  95.      * @Groups("colaborador")
  96.      * @NotUppercase()
  97.      * @var null|string
  98.      */
  99.     public ?string $imageName null;
  100.     /**
  101.      * @return File|null
  102.      */
  103.     public function getImageFile(): ?File
  104.     {
  105.         return $this->imageFile;
  106.     }
  107.     /**
  108.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  109.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  110.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  111.      * must be able to accept an instance of 'File' as the bundle will inject one here
  112.      * during Doctrine hydration.
  113.      *
  114.      * @param File|UploadedFile|null $imageFile
  115.      * @return Colaborador
  116.      * @throws Exception
  117.      */
  118.     public function setImageFile(?File $imageFile null): Colaborador
  119.     {
  120.         $this->imageFile $imageFile;
  121.         if (null !== $imageFile) {
  122.             // It is required that at least one field changes if you are using doctrine
  123.             // otherwise the event listeners won't be called and the file is lost
  124.             $this->updated = new DateTime();
  125.         }
  126.         return $this;
  127.     }
  128. }