コード例 #1
0
ファイル: rule.php プロジェクト: synapsestudios/kohana-acl
 /**
  * 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
0
ファイル: acl.php プロジェクト: synapsestudios/kohana-acl
 /**
  * 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());
     }
 }