Commit e82beebc3a5ae0b05fc758928a4b8b11a8ef047c
1 parent
93a7a3c1
test
Showing
2 changed files
with
14 additions
and
2 deletions
Show diff stats
frontend/controllers/CompanyController.php
... | ... | @@ -259,6 +259,9 @@ |
259 | 259 | ]) |
260 | 260 | ->with('portfolioUsers.gallery') |
261 | 261 | ->one(); |
262 | + if(empty($portfolio)) { | |
263 | + throw new NotFoundHttpException('Портфолио не найдено'); | |
264 | + } | |
262 | 265 | if(!empty( $portfolio_user )) { |
263 | 266 | $portfolio_user = PortfolioUser::find() |
264 | 267 | ->where([ |
... | ... | @@ -347,7 +350,6 @@ |
347 | 350 | if(!$company instanceof User) { |
348 | 351 | throw new BadRequestHttpException('Пользователь не найден'); |
349 | 352 | } |
350 | - | |
351 | 353 | $article = Blog::find() |
352 | 354 | ->where([ |
353 | 355 | 'link' => $link, |
... | ... | @@ -355,6 +357,9 @@ |
355 | 357 | ]) |
356 | 358 | ->with('comments') |
357 | 359 | ->one(); |
360 | + if(empty($article)) { | |
361 | + throw new NotFoundHttpException('Запись не найдена'); | |
362 | + } | |
358 | 363 | $article->updateCounters([ 'view_count' => 1 ]); |
359 | 364 | |
360 | 365 | return $this->render('blog-view', [ | ... | ... |
frontend/controllers/PerformerController.php
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | use yii\web\BadRequestHttpException; |
18 | 18 | use yii\web\Controller; |
19 | 19 | use common\models\User; |
20 | + use yii\web\NotFoundHttpException; | |
20 | 21 | |
21 | 22 | /** |
22 | 23 | * Site controller |
... | ... | @@ -68,7 +69,7 @@ |
68 | 69 | ->one(); |
69 | 70 | |
70 | 71 | if(!$user instanceof User) { |
71 | - throw new BadRequestHttpException('Пользователь не найден'); | |
72 | + throw new NotFoundHttpException('Пользователь не найден'); | |
72 | 73 | } |
73 | 74 | |
74 | 75 | $educations = Fields::getData($user->id, $user->className(), 'education'); |
... | ... | @@ -193,6 +194,9 @@ |
193 | 194 | ]) |
194 | 195 | ->with('portfolioUsers.gallery') |
195 | 196 | ->one(); |
197 | + if(empty($portfolio)) { | |
198 | + throw new NotFoundHttpException('Портфолио не найдено'); | |
199 | + } | |
196 | 200 | if(!empty( $portfolio_user )) { |
197 | 201 | $portfolio_user = PortfolioUser::find() |
198 | 202 | ->where([ |
... | ... | @@ -283,6 +287,9 @@ |
283 | 287 | ]) |
284 | 288 | ->with('comments') |
285 | 289 | ->one(); |
290 | + if(empty($article)) { | |
291 | + throw new NotFoundHttpException('Запись не найдена'); | |
292 | + } | |
286 | 293 | $article->updateCounters([ 'view_count' => 1 ]); |
287 | 294 | |
288 | 295 | return $this->render('blog-view', [ | ... | ... |