<?php
namespace Moto\Service; use Moto; use Zend; class AbstractStaticService { protected static $_request; protected static $_resourceName = null; protected static $_resourcePrivilegesMap = array(); public static function getResourceName() { return static::$_resourceName; } public static function getResourcePrivilege($privilege) { if (isset(static::$_resourcePrivilegesMap[$privilege])) $privilege = static::$_resourcePrivilegesMap[$privilege]; return $privilege; } public static function setRequest($request) { static::$_request = $request; } public static function getRequest() { if (null === static::$_request) { static::setRequest(new Moto\Json\Server\Request()); } return static::$_request; } public static function isAllowed($privilege) { $acl = Moto\Application\Acl\Adapter::getInstance(); $user = Moto\Authentication\Service::getUser(); $userRole = (null === $user ? 'guest' : strtolower($user->role_name)); return $acl->isAllowed($userRole, static::$_resourceName, $privilege); } }