| 1 | <?php |
||
| 13 | class Category |
||
| 14 | { |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @ORM\Column(type="integer") |
||
| 18 | * @ORM\Id |
||
| 19 | * @ORM\GeneratedValue |
||
| 20 | * @var int |
||
| 21 | */ |
||
| 22 | public $id; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @Gedmo\TreePathSource |
||
| 26 | * @ORM\Column(type="string") |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | private $name; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @Gedmo\TreeParent |
||
| 33 | * @ORM\ManyToOne(targetEntity="Category", cascade={"persist"}) |
||
| 34 | * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=TRUE) |
||
| 35 | * @var Category |
||
| 36 | */ |
||
| 37 | private $parent; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @Gedmo\TreePath(separator="|") |
||
| 41 | * @ORM\Column(type="string", nullable=TRUE) |
||
| 42 | * @var string |
||
| 43 | */ |
||
| 44 | private $path; |
||
| 45 | |||
| 46 | |||
| 47 | /** |
||
| 48 | * @param string $name |
||
| 49 | * @param Category $parent |
||
| 50 | */ |
||
| 51 | public function __construct($name, Category $parent = NULL) |
||
| 56 | |||
| 57 | |||
| 58 | /** |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function getName() |
||
| 65 | |||
| 66 | |||
| 67 | /** |
||
| 68 | * @return Category |
||
| 69 | */ |
||
| 70 | public function getParent() |
||
| 74 | |||
| 75 | |||
| 76 | /** |
||
| 77 | * @return string |
||
| 78 | */ |
||
| 79 | public function getPath() |
||
| 83 | |||
| 84 | } |
||
| 85 |