Commit 295dcf32e4542399663cdc8d419ab46a5efe651e

Authored by Alexey Boroda
1 parent 2289b496

-Comments index page fixed

Showing 1 changed file with 19 additions and 5 deletions   Show diff stats
views/manage/index.php
1 <?php 1 <?php
2 use artbox\webcomment\models\CommentModel; 2 use artbox\webcomment\models\CommentModel;
3 use artbox\webcomment\models\CommentModelSearch; 3 use artbox\webcomment\models\CommentModelSearch;
  4 + use MongoDB\Driver\Exception\ExecutionTimeoutException;
4 use yii\data\ActiveDataProvider; 5 use yii\data\ActiveDataProvider;
5 use yii\grid\GridView; 6 use yii\grid\GridView;
6 use yii\helpers\Html; 7 use yii\helpers\Html;
@@ -52,12 +53,25 @@ @@ -52,12 +53,25 @@
52 [ 53 [
53 'label' => \Yii::t('artbox-comment', 'Сущность '), 54 'label' => \Yii::t('artbox-comment', 'Сущность '),
54 'content' => function (CommentModel $model) { 55 'content' => function (CommentModel $model) {
55 - $entity = call_user_func($model->entity.'::find');  
56 - $item = $entity->where(['id' => $model->entity_id])->with(['lang' , 'lang.alias'])->one();  
57 - if ($item !== null){ 56 + try {
  57 + $entity = call_user_func($model->entity . '::find');
  58 + } catch (Exception $exception) {
  59 + return \Yii::$app->formatter->asText('');
  60 + }
  61 + $item = $entity->where([ 'id' => $model->entity_id ])
  62 + ->with(
  63 + [
  64 + 'lang',
  65 + 'lang.alias',
  66 + ]
  67 + )
  68 + ->one();
  69 + if ($item !== null) {
58 if ($urlManagerFrontend = \Yii::$app->get('urlManagerFrontend', false)) { 70 if ($urlManagerFrontend = \Yii::$app->get('urlManagerFrontend', false)) {
59 -  
60 - return "<a href='".$urlManagerFrontend->createUrl(Json::decode($item->lang->alias->route))."'>".$item->lang->title."</a>"; 71 +
  72 + return "<a href='" . $urlManagerFrontend->createUrl(
  73 + Json::decode($item->lang->alias->route)
  74 + ) . "'>" . $item->lang->title . "</a>";
61 } 75 }
62 76
63 return $item->lang->title; 77 return $item->lang->title;