src/Entity/Gos/Uniqskills/Cooperator.php line 22

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