/example/app/Entity/Category.php
https://github.com/prolic/DoctrineExtensions-1 · PHP · 184 lines · 93 code · 32 blank · 59 comment · 0 complexity · 949b681810866db5f21da75b19f04198 MD5 · raw file
- <?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")
- */
- class Category
- {
- /**
- * @ORM\Column(type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue
- */
- private $id;
- /**
- * @Gedmo\Translatable
- * @Gedmo\Slug(fields={"title"})
- * @ORM\Column(length=64, unique=true)
- */
- private $slug;
- /**
- * @Gedmo\Translatable
- * @ORM\Column(length=64)
- */
- private $title;
- /**
- * @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\Translatable
- * @ORM\Column(type="text", nullable=true)
- */
- private $description;
- /**
- * @Gedmo\Timestampable(on="create")
- * @ORM\Column(type="datetime")
- */
- private $created;
- /**
- * @Gedmo\Timestampable(on="update")
- * @ORM\Column(type="datetime")
- */
- private $updated;
- /**
- * Used locale to override Translation listener`s locale
- * @Gedmo\Locale
- */
- private $locale;
- public function __construct()
- {
- $this->children = new ArrayCollection();
- }
- 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 = strip_tags($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 setTranslatableLocale($locale)
- {
- $this->locale = $locale;
- }
- public function __toString()
- {
- return $this->getTitle();
- }
- }