EditorsHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
c 0
b 0
f 0
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A list() 0 10 2
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\View\Helper;
14
15
use Cake\Cache\Cache;
16
use Cake\Utility\Hash;
17
use Cake\View\Helper;
18
19
/**
20
 * Helper for editors
21
 */
22
class EditorsHelper extends Helper
23
{
24
    /**
25
     * Get list of object editors.
26
     *
27
     * @return array
28
     */
29
    public function list(): array
30
    {
31
        $id = (string)Hash::get((array)$this->getView()->get('object'), 'id');
32
        $cached = (string)Cache::read('objects_editors', 'default');
33
        $objectsEditors = (array)json_decode($cached, true);
34
        if (array_key_exists($id, $objectsEditors)) {
35
            return $objectsEditors[$id];
36
        }
37
38
        return [];
39
    }
40
}
41