| Code Coverage | ||||||||||
| Lines | Functions and Methods | Classes and Traits | ||||||||
| Total |  | 0.00% | 0 / 7 |  | 0.00% | 0 / 3 | CRAP |  | 0.00% | 0 / 1 | 
| PermissionManager |  | 0.00% | 0 / 7 |  | 0.00% | 0 / 3 | 30 |  | 0.00% | 0 / 1 | 
| getPermissionModel |  | 0.00% | 0 / 4 |  | 0.00% | 0 / 1 | 6 | |||
| setPermissionModel |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 1 | 2 | |||
| catchEvent |  | 0.00% | 0 / 2 |  | 0.00% | 0 / 1 | 6 | |||
| 1 | <?php | 
| 2 | |
| 3 | /** | 
| 4 | * This program is free software; you can redistribute it and/or | 
| 5 | * modify it under the terms of the GNU General Public License | 
| 6 | * as published by the Free Software Foundation; under version 2 | 
| 7 | * of the License (non-upgradable). | 
| 8 | * | 
| 9 | * This program is distributed in the hope that it will be useful, | 
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 | * GNU General Public License for more details. | 
| 13 | * | 
| 14 | * You should have received a copy of the GNU General Public License | 
| 15 | * along with this program; if not, write to the Free Software | 
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
| 17 | * | 
| 18 | * Copyright (c) 2014 (original work) Open Assessment Technologies SA; | 
| 19 | * | 
| 20 | */ | 
| 21 | |
| 22 | namespace oat\generis\model\data\permission; | 
| 23 | |
| 24 | use oat\generis\model\data\permission\implementation\NoAccess; | 
| 25 | use common_ext_ExtensionsManager; | 
| 26 | use common_Logger; | 
| 27 | use oat\generis\model\data\event\ResourceCreated; | 
| 28 | use oat\oatbox\event\Event; | 
| 29 | use oat\oatbox\service\ServiceManager; | 
| 30 | use oat\oatbox\service\ServiceNotFoundException; | 
| 31 | |
| 32 | /** | 
| 33 | * Proxy for the permission implementation | 
| 34 | * | 
| 35 | * @author Joel Bout <joel@taotesting.com> | 
| 36 | */ | 
| 37 | class PermissionManager | 
| 38 | { | 
| 39 | public const CONFIG_KEY = 'permissions'; | 
| 40 | |
| 41 | /** | 
| 42 | * @return PermissionInterface | 
| 43 | * @deprecated | 
| 44 | */ | 
| 45 | public static function getPermissionModel() | 
| 46 | { | 
| 47 | try { | 
| 48 | return ServiceManager::getServiceManager()->get(PermissionInterface::SERVICE_ID); | 
| 49 | } catch (ServiceNotFoundException $e) { | 
| 50 | common_Logger::w('No permission implementation found'); | 
| 51 | return new NoAccess(); | 
| 52 | } | 
| 53 | } | 
| 54 | |
| 55 | /** | 
| 56 | * @deprecated | 
| 57 | */ | 
| 58 | public static function setPermissionModel(PermissionInterface $model) | 
| 59 | { | 
| 60 | return ServiceManager::getServiceManager()->register(PermissionInterface::SERVICE_ID, $model); | 
| 61 | } | 
| 62 | |
| 63 | public static function catchEvent(Event $event) | 
| 64 | { | 
| 65 | if ($event instanceof ResourceCreated) { | 
| 66 | self::getPermissionModel()->onResourceCreated($event->getResource()); | 
| 67 | } | 
| 68 | } | 
| 69 | } |