Blame view

frontend/components/SeoComponent.php 1.14 KB
14c89ea2   Anastasia   seo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  <?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';
          }
          
      }