本文整理汇总了PHP中UserClass::can方法的典型用法代码示例。如果您正苦于以下问题:PHP UserClass::can方法的具体用法?PHP UserClass::can怎么用?PHP UserClass::can使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserClass
的用法示例。
在下文中一共展示了UserClass::can方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: can
/**
* Determine if this class of user can perform an action or has ability.
*
* @param string $ability
* @return bool
* @throws SCoreException
*/
public function can($ability)
{
if (array_key_exists($ability, $this->abilities)) {
$val = $this->abilities[$ability];
return $val;
} else {
if (!is_null($this->parent)) {
return $this->parent->can($ability);
} else {
global $_shm_user_classes;
$min_dist = 9999;
$min_ability = null;
foreach ($_shm_user_classes['base']->abilities as $a => $cando) {
$v = levenshtein($ability, $a);
if ($v < $min_dist) {
$min_dist = $v;
$min_ability = $a;
}
}
throw new SCoreException("Unknown ability '" . html_escape($ability) . "'. Did the developer mean '" . html_escape($min_ability) . "'?");
}
}
}
示例2: can
/**
* @param string $ability
* @return bool
*/
public function can($ability)
{
return $this->class->can($ability);
}