diff --git a/Seo.php b/Seo.php index 1fc4c44..ee2705c 100644 --- a/Seo.php +++ b/Seo.php @@ -122,21 +122,26 @@ public function setMeta($viewEvent) private function executeSeoControllerAction($viewEvent) { $seoController = Yii::createObject($this->buildSeoControllerClassName()); + + if (!property_exists($this->controller->action, 'actionMethod')) { + return false; + } + $actionMethod = $this->controller->action->actionMethod; - if (method_exists($seoController, $actionMethod)) { - $seoController->controller = $this->controller; - $seoController->view = $viewEvent->sender; + if (!method_exists($seoController, $actionMethod)) { + return false; + } - $meta = $seoController->$actionMethod($viewEvent->params); + $seoController->controller = $this->controller; + $seoController->view = $viewEvent->sender; - $this->addMeta($viewEvent->sender, $meta); - $this->addTitle($viewEvent->sender, $seoController->title); + $meta = $seoController->$actionMethod($viewEvent->params); - return true; - } + $this->addMeta($viewEvent->sender, $meta); + $this->addTitle($viewEvent->sender, $seoController->title); - return false; + return true; } /** diff --git a/composer.json b/composer.json index 2e038cd..7fdb576 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "shershennm/yii2-seo", "description": "Yii2 extension for simple generating keywords and description", - "version": "3.1.0", + "version": "3.1.1", "type": "yii2-extension", "keywords": ["yii2", "seo", "keywords", "meta", "link"], "homepage": "https://github.com/shershennm/yii2-seo",