Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2. namespace Kalamov\Components\Router\Controllers;
  3.  
  4. use Bitrix\Iblock\InheritedProperty\SectionValues;
  5. use Kalamov\Helpers\Cache;
  6.  
  7. abstract class BaseController
  8. {
  9.     /** @var $cacheManager Cache */
  10.     protected $cacheManager;
  11.     protected $section;
  12.  
  13.     public function __construct(array $section)
  14.     {
  15.         $this->cacheManager = new Cache();
  16.         $this->section = $section;
  17.         $this->setRouteProperties();
  18.     }
  19.  
  20.     /**
  21.      * Метод, в котором формируется и возвращается массив данных для последующей записи в $arResult
  22.      *
  23.      * @return array
  24.      */
  25.     abstract public function getData(): array;
  26.  
  27.     /**
  28.      * Устанавливаем Seo информацию из штатной вкладки "SEO" на странице редактирования раздела в админке
  29.      *
  30.      * @return $this
  31.      */
  32.     protected function setRouteProperties(): self
  33.     {
  34.         global $APPLICATION;
  35.  
  36.         $seo = new SectionValues($this->section['IBLOCK_ID'], $this->section['ID']);
  37.  
  38.         $meta = $seo->getValues();
  39.  
  40.         $APPLICATION->SetTitle($meta['SECTION_META_TITLE']);
  41.         $APPLICATION->SetPageProperty('title', $meta['SECTION_META_TITLE']);
  42.         $APPLICATION->SetPageProperty('keywords', $meta['SECTION_META_KEYWORDS']);
  43.         $APPLICATION->SetPageProperty('description', $meta['SECTION_META_DESCRIPTION']);
  44.  
  45.         return $this;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement