本文整理汇总了PHP中ACL::key方法的典型用法代码示例。如果您正苦于以下问题:PHP ACL::key方法的具体用法?PHP ACL::key怎么用?PHP ACL::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACL
的用法示例。
在下文中一共展示了ACL::key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: key
/**
* Calulates the key of this rule based on its scope parts
*
* @return string
*/
public function key()
{
return ACL::key($this->directory, $this->controller, $this->action);
}
示例2: compile
/**
* Compiles the rules based on the scope into a single rule.
*
* @return void
*/
protected function compile()
{
// Initialize an array for the applicable rules
$applicable_rules = array();
// Get the scope for this instance of ACL
$scope = $this->scope();
// Resolve rules that currently have wildcards
ACL::resolve_rules($scope);
// Re-index the scope array with numbers for looping
$scope = array_values($scope);
// Get all the rules that could apply to this request
for ($i = 2; $i >= 0; $i--) {
// Get the key for the scope
$key = ACL::key($scope);
// Look in the rules array for a rule matching the key
if ($rule = Arr::get(self::$_rules, $key, FALSE)) {
$applicable_rules[$key] = $rule;
}
// Remove part of the scope so the next iteration can cascade to another rule
$scope[$i] = '';
}
// Get default rule
$default_key = ACL::KEY_SEPARATOR . ACL::KEY_SEPARATOR;
$applicable_rules[$default_key] = Arr::get(self::$_rules, $default_key);
// Reverse the rules. Compile from the bottom up
$applicable_rules = array_reverse($applicable_rules);
// Compile the rule
foreach ($applicable_rules as $rule) {
$this->rule = Arr::overwrite($this->rule, $rule->as_array());
}
}