/
bitrix-dev
/
Starter-kit
Обзор
Документация
Войти
/
bitrix-dev
/
Starter-kit
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
main
local/php_interface/classes/mwi/Includes/DelayArea.php
85 строк
2 KB
Alexey Karizhenskiy
Первая сборка (из ранее используемого)
19 янв 2026, 21:00
19 янв 2026, 21:00
d843e36
Код
Авторство
О чём код?
<?php namespace MWI\Includes; class DelayArea { private static ?self $instance = null; private string $regionId; private array $recommendations = []; private string $pathFiles = '/include/delay_area/'; private array $files = []; private array $views = []; private function __construct(string $regionId = '') { $this->regionId = $regionId; $this->files = $this->getFiles(); } public static function getInstance(string $regionId = ''): self { if (self::$instance === null) { self::$instance = new self($regionId); } return self::$instance; } private function __clone() {} /** * Получает список файлов с областями * @return array */ private function getFiles(): array { $path = $_SERVER['DOCUMENT_ROOT'] . $this->pathFiles; if (!is_dir($path)) { return []; } return array_map( fn($file) => pathinfo($file, PATHINFO_FILENAME), array_filter( scandir($path), fn($file) => !in_array($file, ['.', '..']) && pathinfo($file, PATHINFO_EXTENSION) === 'php' ) ); } /** * Регистрация отложенного вывода */ public static function ShowViewContent(string $view, array $arParams = []): void { global $APPLICATION; $APPLICATION->ShowViewContent('delay_area:' . $view); $instance = self::getInstance(); $instance->views[] = $view; } /** * Выводит отложенные области */ public static function init(): void { global $APPLICATION; $instance = self::getInstance(); array_walk($instance->views, function($placement) use ($APPLICATION, $instance) { ob_start(); $APPLICATION->IncludeFile( "{$instance->pathFiles}/{$placement}.php", array(), ["MODE" => "php"] ); $APPLICATION->AddViewContent('delay_area:' . $placement, ob_get_contents()); ob_get_clean(); }); } }