Blame view

frontend/models/DirectRedirects.php 1.12 KB
09140c43   Timur Kastemirov   direct 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
39
40
41
42
43
  <?php
      
      namespace frontend\models;
  
      use artbox\core\models\interfaces\RedirectInterface;
      use yii\base\Object;
  
      /**
       * Created by PhpStorm.
       * User: timur
       * Date: 06.11.17
       * Time: 17:43
       */
      
      class DirectRedirects extends Object implements RedirectInterface{
      
          protected $link;
          
          public function doRedirect(string $url): bool
          {
              $redirectArray = [
                  '/site/about'    => '/ru/o-klinike',
                  '/site/gallery'  => '/ru/gallery',
                  '/blog/index'    => '/ru/blog',
                  '/site/price'    => '/ru/price',
                  '/site/contact'  => '/ru/contacts',
                  '/persone/index' => '/ru/persons',
                  '/site/comments' => '/ru/comments',
              ];
              
              if (array_key_exists($url, $redirectArray)){
                  $this->link = $redirectArray[$url];
                  return true;
              }
              
              return false;
          }
          
          public function getLink(): string
          {
              return trim($this->link, "/");
          }
      }