<?php
namespace App\Entity\Gos\Uniqskills;
use App\Entity\Gos\Category;
use App\Entity\Gos\CooperatorGroup;
use App\Entity\Gos\Language;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\CooperatorRepository")
* @Vich\Uploadable
* @ORM\HasLifecycleCallbacks
*/
class Cooperator
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isActive;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $onMainPage;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $visibleInFooter;
/**
* @Assert\NotBlank()
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @Gedmo\Slug(fields={"name"})
* @ORM\Column(type="string", length=191, unique=true)
*/
private $slug;
/**
* @Assert\NotBlank()
* @ORM\Column(type="text", nullable=true)
*/
private $link;
/**
* @ORM\OneToMany(targetEntity="Course", mappedBy="cooperator")
*/
private $course;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Language")
* @ORM\JoinTable(name="cooperator_language",
* joinColumns={@ORM\JoinColumn(name="cooperator_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="language_id", referencedColumnName="id")}
* )
*/
private $languages;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Category", inversedBy="cooperators")
*/
private $categories;
/**
* 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)
*
* @var string
*/
private $imageName;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var \DateTime
*/
private $updatedAt;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\CooperatorGroup", mappedBy="cooperator")
*/
private $cooperatorGroups;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $notForUniqskills;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
private $nip;
public function __construct()
{
$this->course = new ArrayCollection();
$this->languages = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->cooperatorGroups = new ArrayCollection();
}
/**
* 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 Cooperator
*/
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;
}
/**
* @param string $imageName
*
* @return Cooperator
*/
public function setImageName($imageName)
{
$this->imageName = $imageName;
return $this;
}
/**
* @return string|null
*/
public function getImageName()
{
return $this->imageName;
}
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string)$this->name;
}
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 getOnMainPage(): ?bool
{
return $this->onMainPage;
}
public function setOnMainPage(?bool $onMainPage): self
{
$this->onMainPage = $onMainPage;
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 getLink(): ?string
{
return $this->link;
}
public function setLink(?string $link): self
{
$this->link = $link;
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|Course[]
*/
public function getCourse(): Collection
{
return $this->course;
}
public function addCourse(Course $course): self
{
if (!$this->course->contains($course)) {
$this->course[] = $course;
$course->setCooperator($this);
}
return $this;
}
public function removeCourse(Course $course): self
{
if ($this->course->contains($course)) {
$this->course->removeElement($course);
// set the owning side to null (unless already changed)
if ($course->getCooperator() === $this) {
$course->setCooperator(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;
}
/**
* @param $visibleInFooter
* @return $this
*/
public function setVisibleInFooter($visibleInFooter)
{
$this->visibleInFooter = $visibleInFooter;
return $this;
}
/**
* @return boolean
*/
public function getVisibleInFooter()
{
return $this->visibleInFooter;
}
/**
* @return Collection|CooperatorGroup[]
*/
public function getCooperatorGroups(): Collection
{
return $this->cooperatorGroups;
}
public function addCooperatorGroup(CooperatorGroup $cooperatorGroup): self
{
if (!$this->cooperatorGroups->contains($cooperatorGroup)) {
$this->cooperatorGroups[] = $cooperatorGroup;
$cooperatorGroup->addCooperator($this);
}
return $this;
}
public function removeCooperatorGroup(CooperatorGroup $cooperatorGroup): self
{
if ($this->cooperatorGroups->contains($cooperatorGroup)) {
$this->cooperatorGroups->removeElement($cooperatorGroup);
$cooperatorGroup->removeCooperator($this);
}
return $this;
}
public function getNotForUniqskills(): ?bool
{
return $this->notForUniqskills;
}
public function setNotForUniqskills(?bool $notForUniqskills): self
{
$this->notForUniqskills = $notForUniqskills;
return $this;
}
public function getNip(): ?string
{
return $this->nip;
}
public function setNip(?string $nip): self
{
$this->nip = $nip;
return $this;
}
}