src/Entity/Gos/Uniqskills/Author.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills;
  3. use App\Entity\Gos\Category;
  4. use App\Entity\Gos\Language;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. /**
  13.  * @ORM\Table()
  14.  * @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\AuthorRepository")
  15.  * @Vich\Uploadable()
  16.  * @ORM\HasLifecycleCallbacks()
  17.  */
  18. class Author
  19. {
  20.     /**
  21.      * @ORM\Column(type="integer")
  22.      * @ORM\Id()
  23.      * @ORM\GeneratedValue(strategy="IDENTITY")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="boolean", nullable=true)
  28.      */
  29.     private $isActive;
  30.     /**
  31.      * @Assert\NotBlank()
  32.      * @ORM\Column(type="string", length=191)
  33.      */
  34.     private $name;
  35.     /**
  36.      * @Gedmo\Slug(fields={"name"})
  37.      * @ORM\Column(unique=true, length=191)
  38.      */
  39.     private $slug;
  40.     /**
  41.      * @Assert\NotBlank()
  42.      * @ORM\Column(type="text", nullable=true)
  43.      */
  44.     private $content;
  45.     /**
  46.      * @Assert\NotBlank()
  47.      * @ORM\Column(type="text", nullable=true)
  48.      */
  49.     private $achievement;
  50.     /**
  51.      * @ORM\ManyToMany(targetEntity="Module", mappedBy="authors")
  52.      * @ORM\JoinColumn()
  53.      */
  54.     private $module;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity="Lesson", mappedBy="author")
  57.      * @ORM\JoinColumn()
  58.      */
  59.     private $lesson;
  60.     /**
  61.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Language")
  62.      * @ORM\JoinTable(name="author_language",
  63.      *     joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
  64.      *     inverseJoinColumns={@ORM\JoinColumn(name="language_id", referencedColumnName="id")})
  65.      */
  66.     private $languages;
  67.     /**
  68.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category", inversedBy="author")
  69.      * @ORM\JoinTable(name="author_category",
  70.      *     joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
  71.      *     inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
  72.      */
  73.     private $categories;
  74.     /**
  75.      * @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category", inversedBy="programCouncil")
  76.      * @ORM\JoinTable(name="author_categories_program_council")
  77.      */
  78.     private $categoriesProgramCouncil;
  79.     /**
  80.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  81.      *
  82.      * @Assert\File(
  83.      * maxSize="1M",
  84.      * mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
  85.      * )
  86.      *
  87.      * @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
  88.      *
  89.      * @var File
  90.      */
  91.     private $imageFile;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $imageName;
  96.     /**
  97.      * @ORM\Column(type="datetime", nullable=true)
  98.      */
  99.     private $createdAt;
  100.     /**
  101.      * @ORM\Column(type="datetime", nullable=true)
  102.      */
  103.     private $updatedAt;
  104.     public function __construct()
  105.     {
  106.         $this->module = new ArrayCollection();
  107.         $this->lesson = new ArrayCollection();
  108.         $this->languages = new ArrayCollection();
  109.         $this->categories = new ArrayCollection();
  110.         $this->categoriesProgramCouncil = new ArrayCollection();
  111.     }
  112.     /** @ORM\PrePersist() */
  113.     public function prePersist()
  114.     {
  115.         $this->createdAt = new \DateTime();
  116.     }
  117.     /** @ORM\PreUpdate() */
  118.     public function preUpdate()
  119.     {
  120.         $this->updatedAt = new \DateTime();
  121.     }
  122.     public function getId(): ?int
  123.     {
  124.         return $this->id;
  125.     }
  126.     public function getIsActive(): ?bool
  127.     {
  128.         return $this->isActive;
  129.     }
  130.     public function setIsActive(?bool $isActive): self
  131.     {
  132.         $this->isActive $isActive;
  133.         return $this;
  134.     }
  135.     public function getName(): ?string
  136.     {
  137.         return $this->name;
  138.     }
  139.     public function setName(string $name): self
  140.     {
  141.         $this->name $name;
  142.         return $this;
  143.     }
  144.     public function getSlug(): ?string
  145.     {
  146.         return $this->slug;
  147.     }
  148.     public function setSlug(string $slug): self
  149.     {
  150.         $this->slug $slug;
  151.         return $this;
  152.     }
  153.     public function getContent(): ?string
  154.     {
  155.         return $this->content;
  156.     }
  157.     public function setContent(?string $content): self
  158.     {
  159.         $this->content $content;
  160.         return $this;
  161.     }
  162.     public function getAchievement(): ?string
  163.     {
  164.         return $this->achievement;
  165.     }
  166.     public function setAchievement(?string $achievement): self
  167.     {
  168.         $this->achievement $achievement;
  169.         return $this;
  170.     }
  171.     /**
  172.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  173.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  174.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  175.      * must be able to accept an instance of 'File' as the bundle will inject one here
  176.      * during Doctrine hydration.
  177.      *
  178.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  179.      *
  180.      * @return Author
  181.      */
  182.     public function setImageFile(File $image null)
  183.     {
  184.         $this->imageFile $image;
  185.         if ($image) {
  186.             // It is required that at least one field changes if you are using doctrine
  187.             // otherwise the event listeners won't be called and the file is lost
  188.             $this->updatedAt = new \DateTimeImmutable();
  189.         }
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return File|null
  194.      */
  195.     public function getImageFile()
  196.     {
  197.         return $this->imageFile;
  198.     }
  199.     public function getImageName(): ?string
  200.     {
  201.         return $this->imageName;
  202.     }
  203.     public function setImageName(?string $imageName): self
  204.     {
  205.         $this->imageName $imageName;
  206.         return $this;
  207.     }
  208.     public function getCreatedAt(): ?\DateTimeInterface
  209.     {
  210.         return $this->createdAt;
  211.     }
  212.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  213.     {
  214.         $this->createdAt $createdAt;
  215.         return $this;
  216.     }
  217.     public function getUpdatedAt(): ?\DateTimeInterface
  218.     {
  219.         return $this->updatedAt;
  220.     }
  221.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  222.     {
  223.         $this->updatedAt $updatedAt;
  224.         return $this;
  225.     }
  226.     /**
  227.      * @return Collection|Module[]
  228.      */
  229.     public function getModule(): Collection
  230.     {
  231.         return $this->module;
  232.     }
  233.     public function addModule(Module $module): self
  234.     {
  235.         if (!$this->module->contains($module)) {
  236.             $this->module[] = $module;
  237.             $module->addAuthor($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeModule(Module $module): self
  242.     {
  243.         if ($this->module->contains($module)) {
  244.             $this->module->removeElement($module);
  245.             $module->removeAuthor($this);
  246.         }
  247.         return $this;
  248.     }
  249.     /**
  250.      * @return Collection|Lesson[]
  251.      */
  252.     public function getLesson(): Collection
  253.     {
  254.         return $this->lesson;
  255.     }
  256.     public function addLesson(Lesson $lesson): self
  257.     {
  258.         if (!$this->lesson->contains($lesson)) {
  259.             $this->lesson[] = $lesson;
  260.             $lesson->setAuthor($this);
  261.         }
  262.         return $this;
  263.     }
  264.     public function removeLesson(Lesson $lesson): self
  265.     {
  266.         if ($this->lesson->contains($lesson)) {
  267.             $this->lesson->removeElement($lesson);
  268.             // set the owning side to null (unless already changed)
  269.             if ($lesson->getAuthor() === $this) {
  270.                 $lesson->setAuthor(null);
  271.             }
  272.         }
  273.         return $this;
  274.     }
  275.     /**
  276.      * @return Collection|Language[]
  277.      */
  278.     public function getLanguages(): Collection
  279.     {
  280.         return $this->languages;
  281.     }
  282.     public function addLanguage(Language $language): self
  283.     {
  284.         if (!$this->languages->contains($language)) {
  285.             $this->languages[] = $language;
  286.         }
  287.         return $this;
  288.     }
  289.     public function removeLanguage(Language $language): self
  290.     {
  291.         if ($this->languages->contains($language)) {
  292.             $this->languages->removeElement($language);
  293.         }
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return Collection|Category[]
  298.      */
  299.     public function getCategories(): Collection
  300.     {
  301.         return $this->categories;
  302.     }
  303.     public function addCategory(Category $category): self
  304.     {
  305.         if (!$this->categories->contains($category)) {
  306.             $this->categories[] = $category;
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeCategory(Category $category): self
  311.     {
  312.         if ($this->categories->contains($category)) {
  313.             $this->categories->removeElement($category);
  314.         }
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection|Category[]
  319.      */
  320.     public function getCategoriesProgramCouncil(): Collection
  321.     {
  322.         return $this->categoriesProgramCouncil;
  323.     }
  324.     public function addCategoriesProgramCouncil(Category $categoriesProgramCouncil): self
  325.     {
  326.         if (!$this->categoriesProgramCouncil->contains($categoriesProgramCouncil)) {
  327.             $this->categoriesProgramCouncil[] = $categoriesProgramCouncil;
  328.         }
  329.         return $this;
  330.     }
  331.     public function removeCategoriesProgramCouncil(Category $categoriesProgramCouncil): self
  332.     {
  333.         if ($this->categoriesProgramCouncil->contains($categoriesProgramCouncil)) {
  334.             $this->categoriesProgramCouncil->removeElement($categoriesProgramCouncil);
  335.         }
  336.         return $this;
  337.     }
  338. }