|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* BEdita, API-first content management framework |
|
4
|
|
|
* Copyright 2021 ChannelWeb Srl, Chialab Srl |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of BEdita: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU Lesser General Public License as published |
|
8
|
|
|
* by the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details. |
|
12
|
|
|
*/ |
|
13
|
|
|
namespace App\Controller\Model; |
|
14
|
|
|
|
|
15
|
|
|
use Cake\Event\Event; |
|
16
|
|
|
use Cake\Http\Response; |
|
17
|
|
|
use Cake\Utility\Hash; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Categories Model Controller: list, add, edit, remove categories |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
class CategoriesController extends ModelBaseController |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Resource type currently used |
|
27
|
|
|
* |
|
28
|
|
|
* @var string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $resourceType = 'categories'; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Single resource view exists |
|
34
|
|
|
* |
|
35
|
|
|
* @var bool |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $singleView = false; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* {@inheritDoc} |
|
41
|
|
|
*/ |
|
42
|
|
|
public function beforeRender(Event $event): ?Response |
|
43
|
|
|
{ |
|
44
|
|
|
$features = $this->Schema->objectTypesFeatures(); |
|
45
|
|
|
$categorized = (array)Hash::get($features, 'categorized'); |
|
46
|
|
|
$schema = $this->Schema->getSchema(); |
|
47
|
|
|
$schema['properties']['type']['enum'] = $categorized; |
|
48
|
|
|
$filter = (array)$this->request->getQuery('filter'); |
|
49
|
|
|
if (!empty($filter['type'])) { |
|
50
|
|
|
$categorized = [$filter['type']]; |
|
51
|
|
|
} |
|
52
|
|
|
$categorized = array_combine($categorized, $categorized); |
|
53
|
|
|
$this->set(compact('categorized', 'schema')); |
|
54
|
|
|
|
|
55
|
|
|
return parent::beforeRender($event); |
|
|
|
|
|
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.