本文整理汇总了PHP中Zend_Acl::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl::get方法的具体用法?PHP Zend_Acl::get怎么用?PHP Zend_Acl::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Acl
的用法示例。
在下文中一共展示了Zend_Acl::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAllowed
/**
* Notifies whether the logged-in user has permission for a given resource/
* privilege combination.
*
* If an ACL resource being checked has not been defined, access to that
* resource should not be controlled. This allows plugin writers to
* implement controllers without also requiring them to be aware of the ACL.
*
* Conversely, in the event that an ACL resource has been defined, all access
* permissions for that controller must be properly defined.
*
* The names of resources should correspond to the name of the controller
* class minus 'Controller', e.g.
* Geolocation_IndexController -> 'Geolocation_Index'
* CollectionsController -> 'Collections'
*
* @param string $privilege
* @param Zend_Acl_Resource|string|null (Optional) Resource to check.
* @see getResourceName()
* @return boolean
*/
public function isAllowed($privilege, $resource = null)
{
$allowed = $this->_allowed;
if (isset($allowed[$privilege])) {
return $allowed[$privilege];
}
if ($resource instanceof Zend_Acl_Resource_Interface) {
$resourceObj = $resource;
$resourceName = $resourceObj->getResourceId();
} else {
if (is_string($resource)) {
$resourceName = $resource;
} else {
if (!$resource) {
$resourceName = $this->getResourceName();
}
}
}
// Plugin writers do not need to define an ACL in order for their
// controllers to work.
if (!$this->_acl->has($resourceName)) {
return true;
}
if (!isset($resourceObj)) {
$resourceObj = $this->_acl->get($resourceName);
}
return $this->_acl->isAllowed($this->_currentUser, $resourceObj, $privilege);
}
示例2: testResourceAddAndGetOne
/**
* Ensures that basic addition and retrieval of a single Resource works
*
* @return void
*/
public function testResourceAddAndGetOne()
{
$resourceArea = new Zend_Acl_Resource('area');
$resource = $this->_acl->add($resourceArea)->get($resourceArea->getResourceId());
$this->assertTrue($resourceArea === $resource);
$resource = $this->_acl->get($resourceArea);
$this->assertTrue($resourceArea === $resource);
}
示例3: _registerResource
protected function _registerResource($resourceName)
{
$parentRole = null;
$currentResourceName = '';
foreach (explode('.', $resourceName) as $resourceNamePart) {
$currentResourceName = trim($currentResourceName . '.' . $resourceNamePart, '.');
if (!$this->_acl->has($currentResourceName)) {
$this->_acl->addResource($currentResourceName, $parentRole);
}
$parentRole = $this->_acl->get($currentResourceName);
}
}
示例4: get
/** @brief Renvoie la resource
*
* Crée la ressource si elle n'existe pas
* La surcharge de cette méthode de Zend_Acl permet de créer automatiquement
* la ressource si elle n'existe pas quand on fait des allow ou des deny
* par exemple.
*
* @author amboise.lafont
*/
public function get($resource)
{
if (!$this->has($resource)) {
$this->addResource($resource);
}
return parent::get($resource);
}