Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function bootstrap($app)
 {
     /** @var $module Module */
     if ($app->hasModule('qa') && ($module = $app->getModule('qa')) instanceof Module) {
         if ($app instanceof ConsoleApplication) {
             $module->controllerNamespace = 'artkost\\qa\\commands';
         } else {
             if (!class_exists($app->get('user')->identityClass)) {
                 throw new InvalidConfigException('Yii::$app->user->identityClass does not exist');
             }
         }
     }
     $app->i18n->translations[Module::TRANSLATION . '*'] = ['class' => PhpMessageSource::className(), 'basePath' => __DIR__ . '/messages', 'fileMap' => [Module::TRANSLATION . 'main' => 'main.php', Module::TRANSLATION . 'model' => 'model.php']];
     Yii::$container->set('artkost\\qa\\models\\AnswerInterface', Answer::className());
     Yii::$container->set('artkost\\qa\\models\\QuestionInterface', Question::className());
 }
Exemplo n.º 2
0
 /**
  * @return Question
  */
 public function getQuestion()
 {
     return $this->hasOne(Question::className(), ['id' => 'question_id']);
 }
Exemplo n.º 3
0
 /**
  * This is invoked after the record is saved.
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
 }
 public function down()
 {
     $this->dropTable(Question::tableName());
 }
Exemplo n.º 5
0
 /**
  * @param $id
  * @param $vote
  * @return Response
  * @throws NotFoundHttpException
  */
 public function actionQuestionVote($id, $vote)
 {
     return $this->entityVote($this->findModel(Question::className(), $id), $vote);
 }
Exemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $models = Question::find()->published()->views($this->views)->limit($this->limit)->all();
     return $this->render('popular', ['models' => $models]);
 }