| 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 | * @TYPO3\CMS\Extbase\Annotation\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
Loading history...
|
|||
| 67 | return $voters; |
||
| 68 | } |
||
| 69 | |||
| 70 | } |