Example #1
0
 public function init()
 {
     parent::init();
     if ($this->id) {
         /** @var \common\models\Sound $sound */
         $sound = \common\models\Sound::findOne($this->id);
         if ($sound && ($sound->public || Yii::$app->user->can('member'))) {
             $this->_sound = $sound;
         }
     } else {
         throw new InvalidParamException(Yii::t('front', 'No required parameter given') . ' - id');
     }
 }
Example #2
0
 /**
  * Returns sound items for CKEditor sound plugin
  * @return array
  */
 public function actionSoundItems()
 {
     $items = ArrayHelper::map(Sound::find()->all(), 'title', 'id');
     $response = Yii::$app->response;
     $response->format = Response::FORMAT_JSON;
     $response->data = $items;
     return $response;
 }