itstructure /
yii2-template-simple
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace app\controllers; |
||||
| 4 | |||||
| 5 | use yii\web\NotFoundHttpException; |
||||
| 6 | use yii\filters\{AccessControl, VerbFilter}; |
||||
| 7 | use yii\helpers\ArrayHelper; |
||||
| 8 | use Itstructure\MFUploader\models\OwnerMediafile; |
||||
| 9 | use app\models\Article; |
||||
| 10 | |||||
| 11 | /** |
||||
| 12 | * Class ArticleController |
||||
| 13 | * |
||||
| 14 | * @package app\controllers |
||||
| 15 | */ |
||||
| 16 | class ArticleController extends BaseController |
||||
| 17 | { |
||||
| 18 | /** |
||||
| 19 | * @return array |
||||
| 20 | */ |
||||
| 21 | public function behaviors() |
||||
| 22 | { |
||||
| 23 | return ArrayHelper::merge(parent::behaviors(), [ |
||||
| 24 | 'access' => [ |
||||
| 25 | 'class' => AccessControl::class, |
||||
| 26 | 'rules' => [ |
||||
| 27 | [ |
||||
| 28 | 'allow' => true, |
||||
| 29 | 'actions' => ['view'], |
||||
| 30 | 'roles' => ['?', '@'], |
||||
| 31 | ], |
||||
| 32 | ], |
||||
| 33 | ], |
||||
| 34 | 'verbs' => [ |
||||
| 35 | 'class' => VerbFilter::class, |
||||
| 36 | 'actions' => [ |
||||
| 37 | 'view' => ['get'], |
||||
| 38 | ], |
||||
| 39 | ], |
||||
| 40 | ]); |
||||
| 41 | } |
||||
| 42 | |||||
| 43 | /** |
||||
| 44 | * Displays article page. |
||||
| 45 | * |
||||
| 46 | * @return string |
||||
| 47 | * |
||||
| 48 | * @throws NotFoundHttpException |
||||
| 49 | */ |
||||
| 50 | public function actionView($alias) |
||||
| 51 | { |
||||
| 52 | $model = Article::find()->where([ |
||||
| 53 | 'alias' => $alias |
||||
| 54 | ])->andWhere([ |
||||
| 55 | 'active' => 1 |
||||
| 56 | ])->one(); |
||||
| 57 | |||||
| 58 | if (null === $model) { |
||||
| 59 | throw new NotFoundHttpException('Article not fount with alias = '.$alias.'.'); |
||||
| 60 | } |
||||
| 61 | |||||
| 62 | $this->setMetaParams($model); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 63 | |||||
| 64 | $images = OwnerMediafile::getImageFiles(Article::tableName(), $model->id); |
||||
|
0 ignored issues
–
show
It seems like
$model->id can also be of type null; however, parameter $ownerId of Itstructure\MFUploader\m...iafile::getImageFiles() does only seem to accept integer, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 65 | |||||
| 66 | return $this->render('view', [ |
||||
| 67 | 'model' => $model, |
||||
| 68 | 'images' => $images |
||||
| 69 | ]); |
||||
| 70 | } |
||||
| 71 | } |
||||
| 72 |