Category.php 2.21 KB
Newer Older
1
<?php
2

3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
7
8
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
9
 *
10
11
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
14
 * The TYPO3 project - inspiring people to share!
 */
15

16
17
namespace TYPO3\CMS\Extbase\Domain\Model;

18
use TYPO3\CMS\Extbase\Annotation as Extbase;
19
20
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy;
21

22
23
24
/**
 * This model represents a category (for anything).
 */
25
class Category extends AbstractEntity
26
27
28
{
    /**
     * @var string
29
     * @Extbase\Validate("NotEmpty")
30
31
     */
    protected $title = '';
32

33
34
35
36
    /**
     * @var string
     */
    protected $description = '';
37

38
    /**
39
     * @var Category|null
40
     * @Extbase\ORM\Lazy
41
     */
42
    protected $parent;
43

44
45
46
47
48
49
50
51
52
    /**
     * Gets the title.
     *
     * @return string the title, might be empty
     */
    public function getTitle()
    {
        return $this->title;
    }
53

54
55
56
57
58
59
60
61
62
    /**
     * Sets the title.
     *
     * @param string $title the title to set, may be empty
     */
    public function setTitle($title)
    {
        $this->title = $title;
    }
63

64
65
66
67
68
69
70
71
72
    /**
     * Gets the description.
     *
     * @return string the description, might be empty
     */
    public function getDescription()
    {
        return $this->description;
    }
73

74
75
76
77
78
79
80
81
82
    /**
     * Sets the description.
     *
     * @param string $description the description to set, may be empty
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }
83

84
85
86
    /**
     * Gets the parent category.
     *
87
     * @return Category|null the parent category
88
89
90
     */
    public function getParent()
    {
91
        if ($this->parent instanceof LazyLoadingProxy) {
92
93
94
95
            $this->parent->_loadRealInstance();
        }
        return $this->parent;
    }
96

97
98
99
    /**
     * Sets the parent category.
     *
100
     * @param Category $parent the parent category
101
     */
102
    public function setParent(Category $parent)
103
104
105
    {
        $this->parent = $parent;
    }
106
}