123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- <?php
- namespace Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * @Gedmo\Tree(type="nested")
- * @ORM\Table(name="ext_categories")
- * @ORM\Entity(repositoryClass="Entity\Repository\CategoryRepository")
- * @Gedmo\TranslationEntity(class="Entity\CategoryTranslation")
- */
- class Category
- {
- /**
- * @ORM\Column(type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue
- */
- private $id;
- /**
- * @Gedmo\Translatable
- * @ORM\Column(length=64)
- */
- private $title;
- /**
- * @Gedmo\Translatable
- * @ORM\Column(type="text", nullable=true)
- */
- private $description;
- /**
- * @Gedmo\Translatable
- * @Gedmo\Slug(fields={"title"})
- * @ORM\Column(length=64, unique=true)
- */
- private $slug;
- /**
- * @Gedmo\TreeLeft
- * @ORM\Column(type="integer")
- */
- private $lft;
- /**
- * @Gedmo\TreeRight
- * @ORM\Column(type="integer")
- */
- private $rgt;
- /**
- * @Gedmo\TreeParent
- * @ORM\ManyToOne(targetEntity="Category", inversedBy="children")
- * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL")
- */
- private $parent;
- /**
- * @Gedmo\TreeRoot
- * @ORM\Column(type="integer", nullable=true)
- */
- private $root;
- /**
- * @Gedmo\TreeLevel
- * @ORM\Column(name="lvl", type="integer")
- */
- private $level;
- /**
- * @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
- */
- private $children;
- /**
- * @Gedmo\Timestampable(on="create")
- * @ORM\Column(type="datetime")
- */
- private $created;
- /**
- * @Gedmo\Timestampable(on="update")
- * @ORM\Column(type="datetime")
- */
- private $updated;
- /**
- * @ORM\OneToMany(
- * targetEntity="CategoryTranslation",
- * mappedBy="object",
- * cascade={"persist", "remove"}
- * )
- */
- private $translations;
- public function __construct()
- {
- $this->children = new ArrayCollection();
- $this->translations = new ArrayCollection();
- }
- public function getTranslations()
- {
- return $this->translations;
- }
- public function addTranslation(CategoryTranslation $t)
- {
- if (!$this->translations->contains($t)) {
- $this->translations[] = $t;
- $t->setObject($this);
- }
- }
- public function getSlug()
- {
- return $this->slug;
- }
- public function getId()
- {
- return $this->id;
- }
- public function setTitle($title)
- {
- $this->title = $title;
- }
- public function getTitle()
- {
- return $this->title;
- }
- public function setDescription($description)
- {
- $this->description = $description;
- }
- public function getDescription()
- {
- return $this->description;
- }
- public function setParent($parent)
- {
- $this->parent = $parent;
- }
- public function getParent()
- {
- return $this->parent;
- }
- public function getRoot()
- {
- return $this->root;
- }
- public function getLevel()
- {
- return $this->level;
- }
- public function getChildren()
- {
- return $this->children;
- }
- public function getLeft()
- {
- return $this->lft;
- }
- public function getRight()
- {
- return $this->rgt;
- }
- public function getCreated()
- {
- return $this->created;
- }
- public function getUpdated()
- {
- return $this->updated;
- }
- public function __toString()
- {
- return $this->getTitle();
- }
- }
|