src/Entity/StoreManagementRequest.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Symfony\Component\HttpFoundation\File\UploadedFile;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\StoreManagementRequestRepository")
  12.  * @ORM\EntityListeners({"App\Listener\StoreManagementRequestListener"})
  13.  * @Vich\Uploadable
  14.  */
  15. class StoreManagementRequest
  16. {
  17.     const STATE_NEW='new';
  18.     const STATE_VALIDATED='validated';
  19.     const STATE_REJECTED='rejected';
  20.     const TYPE_CREATION='creation';
  21.     const TYPE_ATTACHMENT='attachment';
  22.     const TYPE_SUPPRESSION='suppression';
  23.     public static function getAvailableStates(){
  24.         return [
  25.             self::STATE_NEW=>self::STATE_NEW,
  26.             self::STATE_VALIDATED=>self::STATE_VALIDATED,
  27.             self::STATE_REJECTED=>self::STATE_REJECTED,
  28.         ];
  29.     }
  30.     /**
  31.      * @ORM\Id()
  32.      * @ORM\GeneratedValue()
  33.      * @ORM\Column(type="integer")
  34.      */
  35.     private int $id;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\Store", inversedBy="managementRequests")
  38.      * @ORM\JoinColumn(nullable=false)
  39.      */
  40.     private Store $store;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  43.      * @ORM\JoinColumn(nullable=false)
  44.      * @Gedmo\Blameable(on="create")
  45.      */
  46.     private User $user;
  47.     /**
  48.      * @ORM\Column(type="datetime")
  49.      * @Gedmo\Timestampable(on="create")
  50.      */
  51.     private DateTime  $created;
  52.     /**
  53.      * @ORM\Column(type="datetime", nullable=true)
  54.      */
  55.     private ?DateTime  $validated=null;
  56.     /**
  57.      * @ORM\Column(type="text", nullable=true)
  58.      */
  59.     private ?string $message=null;
  60.     /**
  61.      * @ORM\Column(type="string", length=25, nullable=true)
  62.      */
  63.     private ?string $siretNumber=null;
  64.     /**
  65.      * @ORM\Column(type="string", length=25)
  66.      */
  67.     private string $state=self::STATE_NEW;
  68.     /**
  69.      * @ORM\Column(type="string", length=25)
  70.      */
  71.     private string $type=self::TYPE_ATTACHMENT;
  72.     /**
  73.      * @var File|null
  74.      * @Assert\Image(
  75.      *     mimeTypes={"image/jpeg", "application/pdf"}
  76.      * )
  77.      * @Vich\UploadableField(mapping="storeManagementRequest_kbis", fileNameProperty="filename")
  78.      */
  79.     private ?File $kbisFile=null;
  80.     /**
  81.      * @var string|null
  82.      * @ORM\Column(type="string", length=255, nullable=true)
  83.      */
  84.     private ?string $filename=null;
  85.     /**
  86.      * @ORM\Column(type="datetime")
  87.      * @Gedmo\Timestampable(on="update")
  88.      */
  89.     private DateTime  $updatedAt;
  90.     /**
  91.      * Représente l'entité par défault
  92.      * @return string
  93.      */
  94.     public function __toString(){
  95.         return 'StoreManagementRequest '.' ['.$this->getId().']';
  96.     }
  97.     /**
  98.      * Représente l'entité dans le BO
  99.      * @return string
  100.      */
  101.     public function getLabel(): string
  102.     {
  103.         return 'Demande de gestion du centre '.$this->getStore()->getName();
  104.     }
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     public function getStore(): ?Store
  110.     {
  111.         return $this->store;
  112.     }
  113.     public function setStore(?Store $store): self
  114.     {
  115.         $this->store $store;
  116.         return $this;
  117.     }
  118.     public function getUser(): ?User
  119.     {
  120.         return $this->user;
  121.     }
  122.     public function setUser(?User $user): self
  123.     {
  124.         $this->user $user;
  125.         return $this;
  126.     }
  127.     public function getCreated(): ?\DateTimeInterface
  128.     {
  129.         return $this->created;
  130.     }
  131.     public function setCreated(\DateTimeInterface $created): self
  132.     {
  133.         $this->created $created;
  134.         return $this;
  135.     }
  136.     public function getMessage(): ?string
  137.     {
  138.         return $this->message;
  139.     }
  140.     public function setMessage(?string $message): self
  141.     {
  142.         $this->message $message;
  143.         return $this;
  144.     }
  145.     public function getState(): ?string
  146.     {
  147.         return $this->state;
  148.     }
  149.     public function setState(string $state): self
  150.     {
  151.         $this->state $state;
  152.         return $this;
  153.     }
  154.     public function getType(): ?string
  155.     {
  156.         return $this->type;
  157.     }
  158.     public function setType(string $type): self
  159.     {
  160.         $this->type $type;
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return mixed
  165.      */
  166.     public function getValidated()
  167.     {
  168.         return $this->validated;
  169.     }
  170.     /**
  171.      * @param mixed $validated
  172.      */
  173.     public function setValidated($validated): void
  174.     {
  175.         $this->validated $validated;
  176.     }
  177.     /**
  178.      * @return mixed
  179.      */
  180.     public function getSiretNumber()
  181.     {
  182.         return $this->siretNumber;
  183.     }
  184.     /**
  185.      * @param mixed $siretNumber
  186.      */
  187.     public function setSiretNumber($siretNumber): void
  188.     {
  189.         $siretNumber str_replace(' '''$siretNumber);
  190.         $this->siretNumber $siretNumber;
  191.     }
  192.     /**
  193.      * @return null|File
  194.      */
  195.     public function getKbisFile(): ?File
  196.     {
  197.         return $this->kbisFile;
  198.     }
  199.     /**
  200.      * @param File|null $kbisFile
  201.      * @return StoreManagementRequest
  202.      */
  203.     public function setKbisFile(?File $kbisFile): StoreManagementRequest
  204.     {
  205.         $this->kbisFile $kbisFile;
  206.         if($this->kbisFile instanceof UploadedFile) {
  207.             $this->updatedAt = new DateTime('now');
  208.         }
  209.         return $this;
  210.     }
  211.     /**
  212.      * @return null|string
  213.      */
  214.     public function getFilename(): ?string
  215.     {
  216.         return $this->filename;
  217.     }
  218.     /**
  219.      * @param string|null $filename
  220.      * @return StoreManagementRequest
  221.      */
  222.     public function setFilename(?string $filename): StoreManagementRequest
  223.     {
  224.         $this->filename $filename;
  225.         return $this;
  226.     }
  227. }