<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use App\Repository\ArticleRepository;// use Symfony\Component\DependencyInjection\Loader\Configurator\Traits\ParentTrait;// use Gedmo\Mapping\Annotation as Gedmo;// use Symfony\Component\String\Slugger\AsciiSlugger;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;use App\Entity\BasePost;/** * @ORM\Entity(repositoryClass=ArticleRepository::class) * @UniqueEntity("name") */class Article{ use BasePost; /** * @ORM\Column(type="boolean", nullable=true) */ private $important; /* overriden relations */ /** * @see BasePost * @ORM\ManyToMany(targetEntity="App\Entity\Tag", inversedBy="articles") */ private $tags; /* new relations */ /** * @ORM\ManyToOne(targetEntity="App\Entity\ArticleType", inversedBy="articles") * @ORM\JoinColumn(nullable=false) */ private $type; /** * @ORM\ManyToMany(targetEntity="App\Entity\Media", mappedBy="articles", cascade={"persist", "remove"}) */ private $medias; // /** // * @ORM\ManyToMany(targetEntity="App\Entity\Structure", mappedBy="articles") // * @ORM\OrderBy({"name" = "ASC"}) // */ // private $structures; public function __construct() { // BasePost::__construct(); // $this->structures = new ArrayCollection(); $this->medias = new ArrayCollection(); } public function __toString() { return $this->name; } public function getImportant(): ?bool { return $this->important; } public function isImportant(): ?bool { return $this->important == true; } public function setImportant(?bool $important): self { $this->important = $important; return $this; } public function getType(): ?ArticleType { return $this->type; } public function setType(?ArticleType $type): self { $this->type = $type; return $this; } // /** // * @return Collection|Structure[] // */ // public function getStructures(): Collection // { // return $this->structures; // } // public function addStructure(Structure $structure): self // { // if (!$this->structures->contains($structure)) { // $this->structures[] = $structure; // $structure->addArticle($this); // } // return $this; // } // public function removeStructure(Structure $structure): self // { // if ($this->structures->contains($structure)) { // $this->structures->removeElement($structure); // $structure->removeArticle($this); // } // return $this; // } /** * @return Collection|Media[] */ public function getMedias(): Collection { return $this->medias; } public function addMedia(Media $media): self { if (!$this->medias->contains($media)) { $this->medias[] = $media; $media->addArticle($this); } return $this; } public function removeMedia(Media $media): self { if ($this->medias->contains($media)) { $this->medias->removeElement($media); $media->removeArticle($this); } return $this; } // override BasePost // /** // * @return Collection|Tag[] // */ // public function getTags(): Collection // { // return $this->tags; // } // public function addTag(Tag $tag): self // { // if (!$this->tags->contains($tag)) { // $this->tags[] = $tag; // } // return $this; // } // public function removeTag(Tag $tag): self // { // if ($this->tags->contains($tag)) { // $this->tags->removeElement($tag); // } // return $this; // }}