src/Entity/Project.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\HttpFoundation\File\UploadedFile;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ProjectRepository::class)
  12.  * @Vich\Uploadable
  13.  * @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="Project_cache_entity")
  14.  */
  15. class Project
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\Column(type="text", nullable=true)
  29.      */
  30.     private $content;
  31.     /**
  32.      * @ORM\Column(type="string", length=255, nullable=true)
  33.      */
  34.     private $slug;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="projects")
  37.      * @ORM\JoinColumn(nullable=false)
  38.      */
  39.     private $client;
  40.     /**
  41.      * @ORM\ManyToMany(targetEntity=Category::class, inversedBy="projects")
  42.      */
  43.     private $category// aurait dû Ãªtre au pluriel
  44.     /**
  45.      * @ORM\Column(type="integer")
  46.      */
  47.     private $displayOrder;
  48.     /**
  49.      * @ORM\Column(type="boolean")
  50.      */
  51.     private $isDisplayed true;
  52.     /**
  53.      * @ORM\Column(type="string", length=255)
  54.      * @var string
  55.      */
  56.     private $image;
  57.     /**
  58.      * @Vich\UploadableField(mapping="project_images", fileNameProperty="image")
  59.      * @var File
  60.      */
  61.     private $imageFile;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      * @var string
  65.      */
  66.     private $featuredImage;
  67.     /**
  68.      * @Vich\UploadableField(mapping="project_images", fileNameProperty="featuredImage")
  69.      * @var File
  70.      */
  71.     private $featuredImageFile;
  72.     /**
  73.      * @ORM\Column(type="string", length=255, nullable=true)
  74.      * @var string
  75.      */
  76.     private $gridImage;
  77.     /**
  78.      * @Vich\UploadableField(mapping="project_images", fileNameProperty="gridImage")
  79.      * @var File
  80.      */
  81.     private $gridImageFile;
  82.     /**
  83.      * @ORM\Column(type="datetime", nullable=true)
  84.      * @var \DateTime
  85.      */
  86.     private $updatedAt;
  87.     /**
  88.      * @ORM\Column(type="boolean", nullable=true)
  89.      */
  90.     private $isFeatured false;
  91.     /**
  92.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="projects")
  93.      */
  94.     private $users;
  95.     /**
  96.      * @ORM\OneToMany(targetEntity=Attachment::class, mappedBy="project", orphanRemoval=true, cascade={"persist"})
  97.      */
  98.     private $attachments;
  99.     public function __construct()
  100.     {
  101.         $this->category = new ArrayCollection();
  102.         $this->users = new ArrayCollection();
  103.         $this->attachments = new ArrayCollection();
  104.     }
  105.     public function getId(): ?int
  106.     {
  107.         return $this->id;
  108.     }
  109.     /**
  110.      * @param mixed $id
  111.      */
  112.     public function setId($id): void
  113.     {
  114.         $this->id $id;
  115.     }
  116.     public function getName(): ?string
  117.     {
  118.         return $this->name;
  119.     }
  120.     public function setName(string $name): self
  121.     {
  122.         $this->name $name;
  123.         return $this;
  124.     }
  125.     public function getContent(): ?string
  126.     {
  127.         return $this->content;
  128.     }
  129.     public function setContent(?string $content): self
  130.     {
  131.         $this->content $content;
  132.         return $this;
  133.     }
  134.     public function getSlug(): ?string
  135.     {
  136.         return $this->slug;
  137.     }
  138.     public function setSlug(?string $slug): self
  139.     {
  140.         $this->slug $slug;
  141.         return $this;
  142.     }
  143.     public function getClient(): ?Client
  144.     {
  145.         return $this->client;
  146.     }
  147.     public function setClient(?Client $client): self
  148.     {
  149.         $this->client $client;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection|Category[]
  154.      */
  155.     public function getCategory(): Collection
  156.     {
  157.         return $this->category;
  158.     }
  159.     public function addCategory(Category $category): self
  160.     {
  161.         if (!$this->category->contains($category)) {
  162.             $this->category[] = $category;
  163.         }
  164.         return $this;
  165.     }
  166.     public function removeCategory(Category $category): self
  167.     {
  168.         $this->category->removeElement($category);
  169.         return $this;
  170.     }
  171.     public function getDisplayOrder(): ?int
  172.     {
  173.         return $this->displayOrder;
  174.     }
  175.     public function setDisplayOrder(int $displayOrder): self
  176.     {
  177.         $this->displayOrder $displayOrder;
  178.         return $this;
  179.     }
  180.     public function getIsDisplayed(): ?bool
  181.     {
  182.         return $this->isDisplayed;
  183.     }
  184.     public function setIsDisplayed(bool $isDisplayed): self
  185.     {
  186.         $this->isDisplayed $isDisplayed;
  187.         return $this;
  188.     }
  189.     public function setImageFile(File $image null)
  190.     {
  191.         $this->imageFile $image;
  192.         // VERY IMPORTANT:
  193.         // It is required that at least one field changes if you are using Doctrine,
  194.         // otherwise the event listeners won't be called and the file is lost
  195.         if ($image) {
  196.             // if 'updatedAt' is not defined in your entity, use another property
  197.             $this->updatedAt = new \DateTime('now');
  198.         }
  199.     }
  200.     public function getImageFile()
  201.     {
  202.         return $this->imageFile;
  203.     }
  204.     public function setImage($image)
  205.     {
  206.         $this->image $image;
  207.         return $this;
  208.     }
  209.     public function getImage()
  210.     {
  211.         return $this->image;
  212.     }
  213.     public function getIsFeatured(): ?bool
  214.     {
  215.         return $this->isFeatured;
  216.     }
  217.     public function setIsFeatured(?bool $isFeatured): self
  218.     {
  219.         $this->isFeatured $isFeatured;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection|User[]
  224.      */
  225.     public function getUsers(): Collection
  226.     {
  227.         return $this->users;
  228.     }
  229.     public function addUser(User $user): self
  230.     {
  231.         if (!$this->users->contains($user)) {
  232.             $this->users[] = $user;
  233.             $user->addProject($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeUser(User $user): self
  238.     {
  239.         if ($this->users->removeElement($user)) {
  240.             $user->removeProject($this);
  241.         }
  242.         return $this;
  243.     }
  244.     public function setFeaturedImageFile(File $featuredImage null)
  245.     {
  246.         $this->featuredImageFile $featuredImage;
  247.         // VERY IMPORTANT:
  248.         // It is required that at least one field changes if you are using Doctrine,
  249.         // otherwise the event listeners won't be called and the file is lost
  250.         if ($featuredImage) {
  251.             // if 'updatedAt' is not defined in your entity, use another property
  252.             $this->updatedAt = new \DateTime('now');
  253.         }
  254.     }
  255.     public function getFeaturedImageFile()
  256.     {
  257.         return $this->featuredImageFile;
  258.     }
  259.     public function setFeaturedImage($featuredImage)
  260.     {
  261.         $this->featuredImage $featuredImage;
  262.         return $this;
  263.     }
  264.     public function getFeaturedImage()
  265.     {
  266.         return $this->featuredImage;
  267.     }
  268.     public function setGridImageFile(File $gridImage null)
  269.     {
  270.         $this->gridImageFile $gridImage;
  271.         // VERY IMPORTANT:
  272.         // It is required that at least one field changes if you are using Doctrine,
  273.         // otherwise the event listeners won't be called and the file is lost
  274.         if ($gridImage) {
  275.             // if 'updatedAt' is not defined in your entity, use another property
  276.             $this->updatedAt = new \DateTime('now');
  277.         }
  278.     }
  279.     public function getGridImageFile()
  280.     {
  281.         return $this->gridImageFile;
  282.     }
  283.     public function setGridImage($gridImage)
  284.     {
  285.         $this->gridImage $gridImage;
  286.         return $this;
  287.     }
  288.     public function getGridImage()
  289.     {
  290.         return $this->gridImage;
  291.     }
  292.     /**
  293.      * @return \DateTime
  294.      */
  295.     public function getUpdatedAt(): \DateTime
  296.     {
  297.         return $this->updatedAt;
  298.     }
  299.     /**
  300.      * @param \DateTime $updatedAt
  301.      * @return \DateTime
  302.      */
  303.     public function setUpdatedAt(\DateTime $updatedAt): \DateTime
  304.     {
  305.        return $this->updatedAt $updatedAt;
  306.     }
  307.     /**
  308.      * @return Collection|Attachment[]
  309.      */
  310.     public function getAttachments(): Collection
  311.     {
  312.         return $this->attachments;
  313.     }
  314.     public function addAttachment(Attachment $attachment): self
  315.     {
  316.         if (!$this->attachments->contains($attachment)) {
  317.             $this->attachments[] = $attachment;
  318.             $attachment->setProject($this);
  319.         }
  320.         return $this;
  321.     }
  322.     public function removeAttachment(Attachment $attachment): self
  323.     {
  324.         if ($this->attachments->removeElement($attachment)) {
  325.             // set the owning side to null (unless already changed)
  326.             if ($attachment->getProject() === $this) {
  327.                 $attachment->setProject(null);
  328.             }
  329.         }
  330.         return $this;
  331.     }
  332. }