protected function prepareData()
 {
     $this->auth->insertRule(new AuthorRule());
     $this->auth->createOperation('createPost', 'create a post');
     $this->auth->createOperation('readPost', 'read a post');
     $this->auth->createOperation('updatePost', 'update a post');
     $this->auth->createOperation('deletePost', 'delete a post');
     $task = $this->auth->createTask('updateOwnPost', 'update a post by author himself', 'isAuthor');
     $task->addChild('updatePost');
     $role = $this->auth->createRole('reader');
     $role->addChild('readPost');
     $role = $this->auth->createRole('author');
     $role->addChild('reader');
     $role->addChild('createPost');
     $role->addChild('updateOwnPost');
     $role = $this->auth->createRole('editor');
     $role->addChild('reader');
     $role->addChild('updatePost');
     $role = $this->auth->createRole('admin');
     $role->addChild('editor');
     $role->addChild('author');
     $role->addChild('deletePost');
     $this->auth->assign('reader A', 'reader');
     $this->auth->assign('author B', 'author');
     $this->auth->assign('editor C', 'editor');
     $this->auth->assign('admin D', 'admin');
     $this->auth->assign('reader E', 'reader');
 }
 /**
  * Initializes the application component.
  * This method overrides the parent implementation by establishing the database connection.
  */
 public function init()
 {
     if (is_string($this->db)) {
         $this->db = Yii::$app->getComponent($this->db);
     }
     if (!$this->db instanceof Connection) {
         throw new InvalidConfigException("DbManager::db must be either a DB connection instance or the application component ID of a DB connection.");
     }
     $this->_usingSqlite = !strncmp($this->db->getDriverName(), 'sqlite', 6);
     parent::init();
 }
 /**
  * Initializes the application component.
  * This method overrides parent implementation by loading the authorization data
  * from PHP script.
  */
 public function init()
 {
     parent::init();
     $this->authFile = Yii::getAlias($this->authFile);
     $this->load();
 }