SeoComponent.php 1.14 KB
<?php
    /**
     * Created by PhpStorm.
     * User: stes
     * Date: 02.08.18
     * Time: 12:41
     */
    
    namespace frontend\components;
    
    class SeoComponent extends \artbox\core\components\SeoComponent
    {
        /**
         * @todo Refactor later for sorting and pagination
         * @return string
         */
        public $close = [
            'support',
            'author',
            'book/add',
            'book/success',
            'site/login',
            'site/register'
        ];
        
        public function getRobots()
        {
            if (array_search(\Yii::$app->controller->id, $this->close)){
                return 'noindex, nofollow';
            }
            if (array_search(\Yii::$app->request->pathInfo, $this->close)){
                return 'noindex, nofollow';
            }
        
            if (!empty($this->robots)) {
                return $this->robots;
            }
        
            if (!empty($this->alias) && !empty($this->alias->getRobots())) {
                return $this->alias->getRobots();
            }
        
            return 'index,follow';
        }
        
    }