<?php
namespace App\Entity\Gos\Uniqskills;
use App\Entity\Gos\Category;
use App\Entity\Gos\Language;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\AuthorRepository")
* @Vich\Uploadable()
* @ORM\HasLifecycleCallbacks()
*/
class Author
{
/**
* @ORM\Column(type="integer")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isActive;
/**
* @Assert\NotBlank()
* @ORM\Column(type="string", length=191)
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(unique=true, length=191)
*/
private $slug;
/**
* @Assert\NotBlank()
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @Assert\NotBlank()
* @ORM\Column(type="text", nullable=true)
*/
private $achievement;
/**
* @ORM\ManyToMany(targetEntity="Module", mappedBy="authors")
* @ORM\JoinColumn()
*/
private $module;
/**
* @ORM\OneToMany(targetEntity="Lesson", mappedBy="author")
* @ORM\JoinColumn()
*/
private $lesson;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Language")
* @ORM\JoinTable(name="author_language",
* joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="language_id", referencedColumnName="id")})
*/
private $languages;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category", inversedBy="author")
* @ORM\JoinTable(name="author_category",
* joinColumns={@ORM\JoinColumn(name="author_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")})
*/
private $categories;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category", inversedBy="programCouncil")
* @ORM\JoinTable(name="author_categories_program_council")
*/
private $categoriesProgramCouncil;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Assert\File(
* maxSize="1M",
* mimeTypes={"image/png", "image/jpeg", "image/pjpeg"}
* )
*
* @Vich\UploadableField(mapping="product_image", fileNameProperty="imageName")
*
* @var File
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageName;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
public function __construct()
{
$this->module = new ArrayCollection();
$this->lesson = new ArrayCollection();
$this->languages = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->categoriesProgramCouncil = new ArrayCollection();
}
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getAchievement(): ?string
{
return $this->achievement;
}
public function setAchievement(?string $achievement): self
{
$this->achievement = $achievement;
return $this;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*
* @return Author
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
/**
* @return File|null
*/
public function getImageFile()
{
return $this->imageFile;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(?string $imageName): self
{
$this->imageName = $imageName;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|Module[]
*/
public function getModule(): Collection
{
return $this->module;
}
public function addModule(Module $module): self
{
if (!$this->module->contains($module)) {
$this->module[] = $module;
$module->addAuthor($this);
}
return $this;
}
public function removeModule(Module $module): self
{
if ($this->module->contains($module)) {
$this->module->removeElement($module);
$module->removeAuthor($this);
}
return $this;
}
/**
* @return Collection|Lesson[]
*/
public function getLesson(): Collection
{
return $this->lesson;
}
public function addLesson(Lesson $lesson): self
{
if (!$this->lesson->contains($lesson)) {
$this->lesson[] = $lesson;
$lesson->setAuthor($this);
}
return $this;
}
public function removeLesson(Lesson $lesson): self
{
if ($this->lesson->contains($lesson)) {
$this->lesson->removeElement($lesson);
// set the owning side to null (unless already changed)
if ($lesson->getAuthor() === $this) {
$lesson->setAuthor(null);
}
}
return $this;
}
/**
* @return Collection|Language[]
*/
public function getLanguages(): Collection
{
return $this->languages;
}
public function addLanguage(Language $language): self
{
if (!$this->languages->contains($language)) {
$this->languages[] = $language;
}
return $this;
}
public function removeLanguage(Language $language): self
{
if ($this->languages->contains($language)) {
$this->languages->removeElement($language);
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
}
return $this;
}
public function removeCategory(Category $category): self
{
if ($this->categories->contains($category)) {
$this->categories->removeElement($category);
}
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategoriesProgramCouncil(): Collection
{
return $this->categoriesProgramCouncil;
}
public function addCategoriesProgramCouncil(Category $categoriesProgramCouncil): self
{
if (!$this->categoriesProgramCouncil->contains($categoriesProgramCouncil)) {
$this->categoriesProgramCouncil[] = $categoriesProgramCouncil;
}
return $this;
}
public function removeCategoriesProgramCouncil(Category $categoriesProgramCouncil): self
{
if ($this->categoriesProgramCouncil->contains($categoriesProgramCouncil)) {
$this->categoriesProgramCouncil->removeElement($categoriesProgramCouncil);
}
return $this;
}
}