Blame view

common/models/DirectRedirect.php 903 Bytes
40f60513   Timur Kastemirov   redirects
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
  <?php
      /**
       * Created by PhpStorm.
       * User: timur
       * Date: 22.11.17
       * Time: 11:54
       */
      
      namespace common\models;
      
      use artbox\core\models\interfaces\RedirectInterface;
      use yii\base\Object;
      
      class DirectRedirect extends Object implements RedirectInterface
      {
          
          protected $link;
          
          public function doRedirect(string $url): bool
          {
              $urlArray = array(
                  '/site/index'   => '/ru',
                  '/site/about'   => '/ru/about',
                  '/site/contact' => '/ru/contact',
              );
              if (isset($urlArray[$url])){
                  $this->link = $urlArray[$url];
                  return true;
              }
              
              return false;
          }
          
          public function getLink(): string
          {
              return trim($this->link, "/");
          }
      }