示例#1
0
 /**
  * Private function that parses the hierarchy array and builds up a hierarchy map
  *
  * @param array $hierarchy Role hierarchy array from system configuration.
  */
 private function buildRoleMap($hierarchy)
 {
     $this->map = $this->arr();
     foreach ($hierarchy as $main => $roles) {
         $hierarchy[$main] = $this->arr((array) $roles);
     }
     $hierarchy = $this->arr($hierarchy);
     foreach ($hierarchy as $main => $roles) {
         $this->map->append($main, $roles->val());
         $additionalRoles = clone $roles;
         $parsed = $this->arr();
         $role = '';
         while ($additionalRoles->count() > 0 && $additionalRoles->removeFirst($role)) {
             if (!$hierarchy->keyExists($role)) {
                 continue;
             }
             $parsed->append($role);
             $innerRole = $this->arr($this->map->key($main));
             $innerRole->merge($hierarchy[$role]->val());
             $this->map->append($main, $innerRole->val());
             $additionalRoles->merge($hierarchy->key($role)->diff($parsed->val())->val());
         }
     }
 }
示例#2
0
 /**
  * @dataProvider arraySet1
  */
 public function testAppend($array)
 {
     $a = new ArrayObject($array);
     $a->append('k512');
     array_push($array, 'k512');
     $this->assertSame($array, $a->val());
 }