protected function load()
    {
        $this->children = [];
        $this->rules = [];
        $this->assignments = [];
        $this->items = [];

        $items = $this->loadFromFile($this->itemFile);
        $itemsMtime = @filemtime($this->itemFile);
        $assignments = $this->loadFromFile($this->assignmentFile);
        $assignmentsMtime = @filemtime($this->assignmentFile);
        $rules = $this->loadFromFile($this->ruleFile);

        foreach ($items as $name => $item) {
            $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::class : Role::class;

            $this->items[$name] = new $class([
                'name' => $name,
                'description' => isset($item['description']) ? $item['description'] : null,
                'ruleName' => isset($item['ruleName']) ? $item['ruleName'] : null,
                'data' => isset($item['data']) ? $item['data'] : null,
                'createdAt' => $itemsMtime,
                'updatedAt' => $itemsMtime,
            ]);
        }

        foreach ($items as $name => $item) {
            if (isset($item['children'])) {
                foreach ($item['children'] as $childName) {
                    if (isset($this->items[$childName])) {
                        $this->children[$name][$childName] = $this->items[$childName];
                    }
                }
            }
        }

        foreach ($assignments as $userId => $roles) {
            foreach ($roles as $role) {
                $this->assignments[$userId][$role] = new Assignment([
                    'userId' => $userId,
                    'roleName' => $role,
                    'createdAt' => $assignmentsMtime,
                ]);
            }
        }

        foreach ($rules as $name => $ruleData) {
            $this->rules[$name] = unserialize($ruleData);
        }
    }
protected function load()
    {
        $this->children = [];
        $this->rules = [];
        $this->assignments = [];
        $this->items = [];

        $items = $this->loadFromFile($this->itemFile);
        $itemsMtime = @filemtime($this->itemFile);
        $assignments = $this->loadFromFile($this->assignmentFile);
        $assignmentsMtime = @filemtime($this->assignmentFile);
        $rules = $this->loadFromFile($this->ruleFile);

        foreach ($items as $name => $item) {
            $class = $item['type'] == Item::TYPE_PERMISSION ? Permission::class : Role::class;

            $this->items[$name] = new $class([
                'name' => $name,
                'description' => isset($item['description']) ? $item['description'] : null,
                'ruleName' => isset($item['ruleName']) ? $item['ruleName'] : null,
                'data' => isset($item['data']) ? $item['data'] : null,
                'createdAt' => $itemsMtime,
                'updatedAt' => $itemsMtime,
            ]);
        }

        foreach ($items as $name => $item) {
            if (isset($item['children'])) {
                foreach ($item['children'] as $childName) {
                    if (isset($this->items[$childName])) {
                        $this->children[$name][$childName] = $this->items[$childName];
                    }
                }
            }
        }

        foreach ($assignments as $userId => $roles) {
            foreach ($roles as $role) {
                $this->assignments[$userId][$role] = new Assignment([
                    'userId' => $userId,
                    'roleName' => $role,
                    'createdAt' => $assignmentsMtime,
                ]);
            }
        }

        foreach ($rules as $name => $ruleData) {
            $this->rules[$name] = unserialize($ruleData);
        }
    }
protected function load ( ) { $ this -> children = [ ] ; $ this -> rules = [ ] ; $ this -> assignments = [ ] ; $ this -> items = [ ] ; $ items = $ this -> loadFromFile ( $ this -> itemFile ) ; $ itemsMtime = @ filemtime ( $ this -> itemFile ) ; $ assignments = $ this -> loadFromFile ( $ this -> assignmentFile ) ; $ assignmentsMtime = @ filemtime ( $ this -> assignmentFile ) ; $ rules = $ this -> loadFromFile ( $ this -> ruleFile ) ; foreach ( $ items as $ name => $ item ) { $ class = $ item [ 'type' ] == Item :: TYPE_PERMISSION ? Permission :: class : Role :: class ; $ this -> items [ $ name ] = new $ class ( [ 'name' => $ name , 'description' => isset ( $ item [ 'description' ] ) ? $ item [ 'description' ] : null , 'ruleName' => isset ( $ item [ 'ruleName' ] ) ? $ item [ 'ruleName' ] : null , 'data' => isset ( $ item [ 'data' ] ) ? $ item [ 'data' ] : null , 'createdAt' => $ itemsMtime , 'updatedAt' => $ itemsMtime , ] ) ; } foreach ( $ items as $ name => $ item ) { if ( isset ( $ item [ 'children' ] ) ) { foreach ( $ item [ 'children' ] as $ childName ) { if ( isset ( $ this -> items [ $ childName ] ) ) { $ this -> children [ $ name ] [ $ childName ] = $ this -> items [ $ childName ] ; } } } } foreach ( $ assignments as $ userId => $ roles ) { foreach ( $ roles as $ role ) { $ this -> assignments [ $ userId ] [ $ role ] = new Assignment ( [ 'userId' => $ userId , 'roleName' => $ role , 'createdAt' => $ assignmentsMtime , ] ) ; } } foreach ( $ rules as $ name => $ ruleData ) { $ this -> rules [ $ name ] = unserialize ( $ ruleData ) ; } }
Loads authorization data from persistent storage.
Loads authorization data from persistent storage .