Passed
Pull Request — master (#155)
by
unknown
09:50
created

Voter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getVoters() 0 5 1
1
<?php
2
namespace EWW\Dpf\Security;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Extbase\Object\ObjectManager;
19
20
abstract class Voter
21
{
22
    /**
23
     * security
24
     *
25
     * @var \EWW\Dpf\Security\Security
26
     * @inject
27
     */
28
    protected $security = null;
29
30
    /**
31
     * supported attributes
32
     *
33
     * @var array
34
     */
35
    protected $attributes = array();
36
37
38
    /**
39
     * Determines if the voter supports the given attribute.
40
     *
41
     * @param string $attribute
42
     * @param mixed $subject
43
     * @return mixed
44
     */
45
    abstract public static function supports($attribute, $subject);
46
47
48
    /**
49
     * Determines if access for the given attribute and subject is allowed.
50
     *
51
     * @param string $attribute
52
     * @param mixed $subject
53
     * @return mixed
54
     */
55
    abstract public function voteOnAttribute($attribute, $subject = NULL);
56
57
58
    /**
59
     * Returns all available voters.
60
     *
61
     * @return array
62
     */
63
    public static function getVoters()
64
    {
65
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
66
        $voters[] = $objectManager->get(\EWW\Dpf\Security\DocumentVoter::class);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$voters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $voters = array(); before regardless.
Loading history...
67
        return $voters;
68
    }
69
70
}