Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
StubProcessor.php
1<?php
2
4
7use CMain;
8
25{
26 private const OPTION_SKIPED_PAGES = 'skip_stub_pages';
27
35 public function addSkippedPage(string $page): void
36 {
37 $pages = $this->getSkippedPages();
38 $pages[$page] = true;
39
40 Option::set('ui', self::OPTION_SKIPED_PAGES, json_encode($pages));
41 }
42
48 private function getSkippedPages(): array
49 {
50 $pages = Option::get('ui', self::OPTION_SKIPED_PAGES);
51 if (!empty($pages))
52 {
53 $pages = json_decode($pages, true);
54 if (is_array($pages))
55 {
56 return $pages;
57 }
58 }
59
60 return [];
61 }
62
70 public function isShowStub(?string $page = null): bool
71 {
72 $page ??= Context::getCurrent()->getRequest()->getRequestedPage();
73 $skippedPages = $this->getSkippedPages();
74
75 return !isset($skippedPages[$page]);
76 }
77
86 public function showStub(string $title, ?string $linkToNewPage): void
87 {
88 global $APPLICATION;
89
94 $APPLICATION->IncludeComponent('bitrix:ui.admin.page.stub', '', [
95 'TITLE' => $title,
96 'STUB_PROCESSOR' => $this,
97 'LINK_TO_NEW_PAGE' => $linkToNewPage,
98 ]);
99 }
100}
static getCurrent()
Definition context.php:241