1 | <?php |
||
49 | class Categories { |
||
50 | use |
||
51 | CRUD_helpers, |
||
52 | Singleton; |
||
53 | |||
54 | const VISIBLE = 1; |
||
55 | const INVISIBLE = 0; |
||
56 | |||
57 | protected $data_model = [ |
||
58 | 'id' => 'int:1', |
||
59 | 'parent' => 'int:0', |
||
60 | 'title' => 'ml:text', |
||
61 | 'description' => 'ml:html', |
||
62 | 'title_attribute' => 'int:1', |
||
63 | 'description_attribute' => 'int:1', |
||
64 | 'image' => 'string', |
||
65 | 'visible' => 'int:0..1', |
||
66 | 'attributes' => [ |
||
67 | 'data_model' => [ |
||
68 | 'id' => 'int:1', |
||
69 | 'attribute' => 'int:1' |
||
70 | ] |
||
71 | ] |
||
72 | ]; |
||
73 | protected $table = '[prefix]shop_categories'; |
||
74 | protected $data_model_ml_group = 'Shop/categories'; |
||
75 | protected $data_model_files_tag_prefix = 'Shop/categories'; |
||
76 | /** |
||
77 | * @var Prefix |
||
78 | */ |
||
79 | protected $cache; |
||
80 | |||
81 | protected function construct () { |
||
84 | /** |
||
85 | * Returns database index |
||
86 | * |
||
87 | * @return int |
||
88 | */ |
||
89 | protected function cdb () { |
||
92 | /** |
||
93 | * Get category |
||
94 | * |
||
95 | * @param int|int[] $id |
||
96 | * |
||
97 | * @return array|false |
||
98 | */ |
||
99 | function get ($id) { |
||
129 | /** |
||
130 | * Get category data for specific user (some categories may be restricted and so on) |
||
131 | * |
||
132 | * @param int|int[] $id |
||
133 | * @param bool|int $user |
||
134 | * |
||
135 | * @return array|false |
||
136 | */ |
||
137 | function get_for_user ($id, $user = false) { |
||
161 | /** |
||
162 | * Get array of all categories |
||
163 | * |
||
164 | * @return int[] Array of categories ids |
||
165 | */ |
||
166 | function get_all () { |
||
174 | /** |
||
175 | * @param int[] $attributes |
||
176 | * |
||
177 | * @return int[] |
||
178 | */ |
||
179 | protected function clean_nonexistent_attributes ($attributes) { |
||
194 | /** |
||
195 | * Add new category |
||
196 | * |
||
197 | * @param int $parent |
||
198 | * @param string $title |
||
199 | * @param string $description |
||
200 | * @param int $title_attribute Attribute that will be considered as title |
||
201 | * @param int $description_attribute Attribute that will be considered as description |
||
202 | * @param string $image |
||
203 | * @param int $visible `Categories::VISIBLE` or `Categories::INVISIBLE` |
||
204 | * @param int[] $attributes Array of attributes ids used in category |
||
205 | * |
||
206 | * @return false|int Id of created category on success of <b>false</> on failure |
||
1 ignored issue
–
show
|
|||
207 | */ |
||
208 | function add ($parent, $title, $description, $title_attribute, $description_attribute, $image, $visible, $attributes) { |
||
231 | /** |
||
232 | * Set data of specified category |
||
233 | * |
||
234 | * @param int $id |
||
235 | * @param int $parent |
||
236 | * @param string $title |
||
237 | * @param string $description |
||
238 | * @param int $title_attribute Attribute that will be considered as title |
||
239 | * @param int $description_attribute Attribute that will be considered as description |
||
240 | * @param string $image |
||
241 | * @param int $visible `Categories::VISIBLE` or `Categories::INVISIBLE` |
||
242 | * @param int[] $attributes Array of attributes ids used in category |
||
243 | * |
||
244 | * @return bool |
||
245 | */ |
||
246 | function set ($id, $parent, $title, $description, $title_attribute, $description_attribute, $image, $visible, $attributes) { |
||
274 | /** |
||
275 | * Delete specified category |
||
276 | * |
||
277 | * @param int $id |
||
278 | * |
||
279 | * @return bool |
||
280 | */ |
||
281 | function del ($id) { |
||
298 | } |
||
299 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.