src/Entity/Document.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DocumentRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. #[ORM\Entity(repositoryClassDocumentRepository::class)]
  10. class Document
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column(type'integer')]
  15.     private $id;
  16.     #[ORM\Column(type'string'length255nullabletrue)]
  17.     private $code;
  18.     #[ORM\Column(type'text')]
  19.     private $nom;
  20.     #[ORM\Column(type'string'length255nullabletrue)]
  21.     private $nature;
  22.     #[ORM\ManyToOne(targetEntityTypeDocument::class, inversedBy'documents')]
  23.     private $typedocument;
  24.     #[ORM\Column(type'text')]
  25.     private $description;
  26.     #[Gedmo\Timestampable(on'create')]
  27.     #[ORM\Column(type'datetime')]
  28.     private $created_at;
  29.     #[Gedmo\Timestampable(on'update')]
  30.     #[ORM\Column(type'datetime')]
  31.     private $updated_at;
  32.     #[ORM\Column(type'integer')]
  33.     private $created_by;
  34.     #[ORM\Column(type'integer')]
  35.     private $updated_by;
  36.     #[ORM\Column(type'string'length255nullabletrue)]
  37.     private $file;
  38.     #[ORM\Column]
  39.     private ?bool $access false;
  40.     #[ORM\ManyToOne(inversedBy'documents')]
  41.     private ?Groupe $groupe null;
  42.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  43.     private ?\DateTimeInterface $datepublication null;
  44.     #[ORM\Column(typeTypes::DATE_MUTABLEnullabletrue)]
  45.     private ?\DateTimeInterface $datepublicationpublic null;
  46.     #[ORM\OneToMany(mappedBy'document'targetEntityCommentaire::class)]
  47.     private Collection $commentaires;
  48.     #[ORM\Column(type'json')]
  49.     private $roles = [];
  50.     public function __construct()
  51.     {
  52.         $this->commentaires = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getCode(): ?string
  59.     {
  60.         return $this->code;
  61.     }
  62.     public function setCode(?string $code): self
  63.     {
  64.         $this->code $code;
  65.         return $this;
  66.     }
  67.     public function getNom(): ?string
  68.     {
  69.         return $this->nom;
  70.     }
  71.     public function setNom(string $nom): self
  72.     {
  73.         $this->nom $nom;
  74.         return $this;
  75.     }
  76.     public function getNature(): ?string
  77.     {
  78.         return $this->nature;
  79.     }
  80.     public function setNature(?string $nature): self
  81.     {
  82.         $this->nature $nature;
  83.         return $this;
  84.     }
  85.     public function getTypedocument(): ?TypeDocument
  86.     {
  87.         return $this->typedocument;
  88.     }
  89.     public function setTypedocument(?TypeDocument $typedocument): self
  90.     {
  91.         $this->typedocument $typedocument;
  92.         return $this;
  93.     }
  94.     public function getDescription(): ?string
  95.     {
  96.         return $this->description;
  97.     }
  98.     public function setDescription(string $description): self
  99.     {
  100.         $this->description $description;
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?\DateTimeInterface
  104.     {
  105.         return $this->created_at;
  106.     }
  107.     public function setCreatedAt(\DateTimeInterface $created_at): self
  108.     {
  109.         $this->created_at $created_at;
  110.         return $this;
  111.     }
  112.     public function getUpdatedAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->updated_at;
  115.     }
  116.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  117.     {
  118.         $this->updated_at $updated_at;
  119.         return $this;
  120.     }
  121.     public function getCreatedBy(): ?int
  122.     {
  123.         return $this->created_by;
  124.     }
  125.     public function setCreatedBy(int $created_by): self
  126.     {
  127.         $this->created_by $created_by;
  128.         return $this;
  129.     }
  130.     public function getUpdatedBy(): ?int
  131.     {
  132.         return $this->updated_by;
  133.     }
  134.     public function setUpdatedBy(int $updated_by): self
  135.     {
  136.         $this->updated_by $updated_by;
  137.         return $this;
  138.     }
  139.     public function getFile(): ?string
  140.     {
  141.         return $this->file;
  142.     }
  143.     public function setFile(?string $file): self
  144.     {
  145.         $this->file $file;
  146.         return $this;
  147.     }
  148.     public function isAccess(): ?bool
  149.     {
  150.         return $this->access;
  151.     }
  152.     public function setAccess(bool $access): self
  153.     {
  154.         $this->access $access;
  155.         return $this;
  156.     }
  157.     public function getGroupe(): ?Groupe
  158.     {
  159.         return $this->groupe;
  160.     }
  161.     public function setGroupe(?Groupe $groupe): self
  162.     {
  163.         $this->groupe $groupe;
  164.         return $this;
  165.     }
  166.     public function getDatepublication(): ?\DateTimeInterface
  167.     {
  168.         return $this->datepublication;
  169.     }
  170.     public function setDatepublication(?\DateTimeInterface $datepublication): self
  171.     {
  172.         $this->datepublication $datepublication;
  173.         return $this;
  174.     }
  175.     public function getDatepublicationpublic(): ?\DateTimeInterface
  176.     {
  177.         return $this->datepublicationpublic;
  178.     }
  179.     public function setDatepublicationpublic(?\DateTimeInterface $datepublicationpublic): self
  180.     {
  181.         $this->datepublicationpublic $datepublicationpublic;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return Collection<int, Commentaire>
  186.      */
  187.     public function getCommentaires(): Collection
  188.     {
  189.         return $this->commentaires;
  190.     }
  191.     public function addCommentaire(Commentaire $commentaire): self
  192.     {
  193.         if (!$this->commentaires->contains($commentaire)) {
  194.             $this->commentaires->add($commentaire);
  195.             $commentaire->setDocument($this);
  196.         }
  197.         return $this;
  198.     }
  199.     public function removeCommentaire(Commentaire $commentaire): self
  200.     {
  201.         if ($this->commentaires->removeElement($commentaire)) {
  202.             // set the owning side to null (unless already changed)
  203.             if ($commentaire->getDocument() === $this) {
  204.                 $commentaire->setDocument(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     public function getRoles(): array
  210.     {
  211.         $roles $this->roles;
  212.         return array_unique($roles);
  213.     }
  214.     public function setRoles(array $roles): self
  215.     {
  216.         $this->roles $roles;
  217.         return $this;
  218.     }
  219.     public function hasRole($role)
  220.     {
  221.         return in_array($role$this->getRoles(), true);
  222.     }
  223.     public function addRole($role)
  224.     {
  225.         if (!in_array($role$this->rolestrue)) {
  226.             $this->roles[] = $role;
  227.         }
  228.         return $this;
  229.     }
  230.     public function removeRole($role)
  231.     {
  232.         if (false !== $key array_search($role$this->rolestrue)) {
  233.             unset($this->roles[$key]);
  234.             $this->roles array_values($this->roles);
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeAllRole(): self
  239.     {
  240.         foreach ($this->roles as $role) {
  241.             $this->removeRole($role);
  242.         }
  243.         return $this;
  244.     }
  245. }