コード例 #1
0
 public function beforeAction($action)
 {
     if (parent::beforeAction($action)) {
         if ($action->id !== 'create') {
             if (is_string($this->db)) {
                 $this->db = Yii::$app->get($this->db);
             }
             if (!$this->db instanceof Connection) {
                 throw new Exception("The 'db' option must refer to the application component ID of a DB connection.");
             }
             if ($this->db->schema->getTableSchema(User::tableName(), true) === null) {
                 throw new Exception("The '" . User::tableName() . "' table does not exist.");
             }
         }
         $version = Yii::getVersion();
         echo "Maddoger`s User Creation tool (based on Yii v{$version})\n\n";
         return true;
     } else {
         return false;
     }
 }
コード例 #2
0
ファイル: AuthItem.php プロジェクト: maddoger/yii2-user
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(User::className(), ['id' => 'user_id'])->viaTable(User::tableName(), ['item_name' => 'name']);
 }