Example #1
0
 public function __construct()
 {
     $model = new AclModel();
     $roles = $model->getRoles();
     foreach ($roles as $role) {
         //        	dump($role['key_name'], $role['parent_key']);
         $this->addRole($role['key_name'], $role['parent_key']);
     }
     $resources = $model->getResources();
     foreach ($resources as $resource) {
         //        	dump($resource['key_name'], $resource['parent_key']);
         $this->addResource($resource['key_name'], $resource['parent_key']);
     }
     foreach ($model->getRules() as $rule) {
         if (!is_null($rule->assertion)) {
             $rule->assertion = new $rule->assertion();
         }
         //        	dump($rule->access ? 'allow' : 'deny', $rule->role, $rule->resource, $rule->privilege, $rule->assertion);
         $this->{$rule->access ? 'allow' : 'deny'}($rule->role, $rule->resource, $rule->privilege, $rule->assertion);
     }
     //        die();
 }
Example #2
0
 public function __construct()
 {
     $model = new AclModel();
     $roles = $model->getRoles();
     foreach ($roles as $role) {
         $this->addRole($role['key_name'], $role['parent_key']);
     }
     $model->getResources();
     foreach ($model->getResources() as $resource) {
         $this->addResource($resource['key_name'], $resource['parent_key']);
     }
     foreach ($model->getRules() as $rule) {
         $this->{$rule->access ? 'allow' : 'deny'}($rule->role, $rule->resource, $rule->privilege);
     }
 }