Пример #1
0
 private function getResourcePath($id)
 {
     if (($res = Resources::findOne($id)) !== null) {
         $path = $res->alias;
         $path = $this->getCategoryPath($res->category_id) . $path;
     } else {
         $path = '#wrs-' . $id;
     }
     return $path;
 }
Пример #2
0
 private function getStoreInfo()
 {
     $path = [];
     switch ($this->tableId) {
         case Resources::$tableId:
             $model = Resources::findOne($this->id);
             $handler = $model->category->handler;
             $route = $model->route;
             break;
         case Categories::$tableId:
             $model = Categories::findOne($this->id);
             $handler = $model->handler;
             $route = $model->route;
             break;
         default:
             throw new InvalidConfigException('FileUploadModel - неизвестный ID таблицы');
             break;
     }
     $contrClass = Yii::$app->controllerNamespace . '\\' . ucfirst($handler) . 'Controller';
     $path = $contrClass::baseStorePath();
     $path['route'] = $route;
     return $path;
 }
Пример #3
0
 /**
  */
 protected function findModel($id)
 {
     if (($model = Resources::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #4
0
 protected function findAlbum($id)
 {
     if (($model = Resources::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Ресурс не найден');
     }
 }
Пример #5
0
 protected function findModel($id)
 {
     if ($id != 0) {
         if (($model = Resources::findOne($id)) !== null) {
             return $model;
         }
     } else {
         if (($model = Categories::findByAlias('0', 0)->resources[0]) !== null) {
             return $model;
         }
     }
     throw new NotFoundHttpException('The requested page does not exist.');
 }