Commit 09140c4348a0f492932be430661465b33691e490

Authored by Timur Kastemirov
1 parent dd34be36

direct redirects

frontend/config/main.php
1 1 <?php
2 2 use artbox\core\components\LanguageRequest;
3 3 use artbox\core\components\SeoUrlManager;
  4 + use frontend\models\DirectRedirects;
4 5  
5 6 $params = array_merge(
6 7 require( __DIR__ . '/../../common/config/params.php' ),
... ... @@ -51,6 +52,9 @@
51 52 'urlManager' => [
52 53 'class' => SeoUrlManager::className(),
53 54 'enablePrettyUrl' => true,
  55 + 'redirects' => [
  56 + DirectRedirects::className(),
  57 + ],
54 58 'showScriptName' => false,
55 59 'processRoutes' => [
56 60 'page/view',
... ...
frontend/models/DirectRedirects.php 0 → 100644
  1 +<?php
  2 +
  3 + namespace frontend\models;
  4 +
  5 + use artbox\core\models\interfaces\RedirectInterface;
  6 + use yii\base\Object;
  7 +
  8 + /**
  9 + * Created by PhpStorm.
  10 + * User: timur
  11 + * Date: 06.11.17
  12 + * Time: 17:43
  13 + */
  14 +
  15 + class DirectRedirects extends Object implements RedirectInterface{
  16 +
  17 + protected $link;
  18 +
  19 + public function doRedirect(string $url): bool
  20 + {
  21 + $redirectArray = [
  22 + '/site/about' => '/ru/o-klinike',
  23 + '/site/gallery' => '/ru/gallery',
  24 + '/blog/index' => '/ru/blog',
  25 + '/site/price' => '/ru/price',
  26 + '/site/contact' => '/ru/contacts',
  27 + '/persone/index' => '/ru/persons',
  28 + '/site/comments' => '/ru/comments',
  29 + ];
  30 +
  31 + if (array_key_exists($url, $redirectArray)){
  32 + $this->link = $redirectArray[$url];
  33 + return true;
  34 + }
  35 +
  36 + return false;
  37 + }
  38 +
  39 + public function getLink(): string
  40 + {
  41 + return trim($this->link, "/");
  42 + }
  43 + }
0 44 \ No newline at end of file
... ...