public function authorize($subject, $page, $task) { // 1. Load the rules table $rulesTable = $this->rulesStorage->loadTable(); // 2. Get roles from subject if (empty($subject)) { $roles[] = '*'; } else { $roles = $this->roleStorage->getRoles($subject); if (empty($roles)) { $roles[] = '*'; } } // 3. Check if subject is authorized foreach ($roles as $role) { if ($rulesTable->hasMatch($role, $page, $task)) { return true; } } return false; }
protected function tearDown() { $this->roleStorage->remove(); $this->rulesStorage->remove(); }