/administrator/components/com_widgetkit/vendor/yootheme/framework/src/User/AccessListener.php
https://gitlab.com/vnsoftdev/amms · PHP · 30 lines · 22 code · 5 blank · 3 comment · 1 complexity · 385ceb84ba65058d7a4a19434321e02f MD5 · raw file
- <?php
- namespace YOOtheme\Framework\User;
- use YOOtheme\Framework\Event\EventSubscriberInterface;
- use YOOtheme\Framework\Routing\Exception\HttpException;
- class AccessListener implements EventSubscriberInterface
- {
- public function onRequest($event, $app)
- {
- $access = (array) $event['request']->attributes->get('access');
- foreach ($access as $permission) {
- if (!$app['user']->hasPermission($permission)) {
- throw new HttpException(403, 'Insufficient User Rights.');
- }
- }
- }
- /**
- * {@inheritdoc}
- */
- public static function getSubscribedEvents()
- {
- return array(
- 'request' => array('onRequest', -10)
- );
- }
- }