1 | <?php |
||
11 | trait CategoryTrait |
||
12 | { |
||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $categoryItemType; |
||
17 | |||
18 | /** |
||
19 | * @var \Charcoal\Object\CategorizableInterface[]|array |
||
20 | */ |
||
21 | private $categoryItems; |
||
22 | |||
23 | /** |
||
24 | * @var integer |
||
25 | */ |
||
26 | private $numCategoryItems; |
||
27 | |||
28 | /** |
||
29 | * @param string $type The category item type. |
||
30 | * @throws InvalidArgumentException If the type argument is not a string. |
||
31 | * @return self |
||
32 | */ |
||
33 | public function setCategoryItemType($type) |
||
43 | |||
44 | /** |
||
45 | * @throws Exception If no item type was previously set. |
||
46 | * @return string |
||
47 | */ |
||
48 | public function getCategoryItemType() |
||
57 | |||
58 | /** |
||
59 | * Alias of {@see self::getCategoryItemType()}. |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function categoryItemType() |
||
67 | |||
68 | /** |
||
69 | * Gets the number of items, directly within this category. |
||
70 | * |
||
71 | * @return integer |
||
72 | */ |
||
73 | public function getNumCategoryItems() |
||
88 | |||
89 | /** |
||
90 | * Alias of {@see self::getNumCategoryItems()}. |
||
91 | * |
||
92 | * @return integer |
||
93 | */ |
||
94 | public function numCategoryItems() |
||
98 | |||
99 | /** |
||
100 | * Gets wether the category has any items, directly within it. |
||
101 | * |
||
102 | * @return boolean |
||
103 | */ |
||
104 | public function hasCategoryItems() |
||
109 | |||
110 | /** |
||
111 | * Retrieves the category items, directly within it. |
||
112 | * |
||
113 | * @return \Charcoal\Object\CategorizableInterface[]|array A list of `CategorizableInterface` objects |
||
114 | */ |
||
115 | public function getCategoryItems() |
||
123 | |||
124 | /** |
||
125 | * Loads the category items (directly within it). |
||
126 | * |
||
127 | * This method is abstract so must be reimplemented. |
||
128 | * Typically, a class would use a CollectionLoader to load the category items. |
||
129 | * |
||
130 | * @return \Charcoal\Object\CategorizableInterface[]|array |
||
131 | */ |
||
132 | abstract protected function loadCategoryItems(); |
||
133 | } |
||
134 |