Completed
Branch user-caps-n-site-permissions (6f6d8f)
by
unknown
41:20 queued 31:50
created

SitePermissions::initialize()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 16
rs 9.7333
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\data_nodes\core;
4
5
use EventEspresso\core\services\json\JsonDataNode;
6
use EventEspresso\core\services\json\JsonDataNodeValidator;
7
8
class SitePermissions extends JsonDataNode
9
{
10
    const NODE_NAME = 'sitePermissions';
11
12
    /**
13
     * @param JsonDataNodeValidator $validator
14
     */
15
    public function __construct(JsonDataNodeValidator $validator)
16
    {
17
        parent::__construct($validator);
18
        $this->setNodeName(SitePermissions::NODE_NAME);
19
    }
20
21
    /**
22
     * @inheritDoc
23
     */
24
    public function initialize()
25
    {
26
        $permissions = [];
27
        $site_permissions = apply_filters(
28
            'FHEE__EventEspresso_core_domain_entities_routing_data_nodes_core_SitePermissions__initialize__site_permissions',
29
            [
30
                'use_bulk_edit' => true,
31
            ]
32
        );
33
        foreach ($site_permissions as $permission => $you_can_do_it) {
34
            if ($you_can_do_it) {
35
                $permissions[] = $permission;
36
            }
37
        }
38
        $this->setDataArray($permissions);
39
    }
40
}
41