Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/yandex.market/lib/ui/admin/ |
Upload File : |
<?php namespace Yandex\Market\Ui\Admin; use Yandex\Market; use Bitrix\Main; class Menu extends Market\Reference\Event\Regular { use Market\Reference\Concerns\HasLang; protected static function includeMessages() { Main\Localization\Loc::loadMessages(__FILE__); } public static function getHandlers() { return [ [ 'module' => 'main', 'event' => 'OnBuildGlobalMenu', ], ]; } public static function onBuildGlobalMenu(&$globalMenu, &$moduleMenu) { $menuIndexes = static::searchModuleSections($moduleMenu, 'yamarket_'); if (!empty($menuIndexes)) { $globalSection = static::getGlobalSection(); $globalSectionId = $globalSection['items_id']; static::moveMenuToParent($moduleMenu, $menuIndexes, $globalSectionId); $globalMenu[$globalSectionId] = $globalSection; } } protected static function getGlobalSection() { return [ 'menu_id' => 'yamarket', 'text' => static::getLang('UI_ADMIN_MENU_TEXT'), 'title' => static::getLang('UI_ADMIN_MENU_TITLE'), 'sort' => 310, 'items_id' => 'global_menu_yamarket', 'items' => [] ]; } protected static function searchModuleSections($moduleMenu, $prefix) { $result = []; foreach ($moduleMenu as $menuIndex => $menu) { if ( isset($menu['section']) && is_string($menu['section']) && Market\Data\TextString::getPosition($menu['section'], $prefix) === 0 ) { $result[] = $menuIndex; } } return $result; } protected static function moveMenuToParent(&$moduleMenu, $indexes, $parentName) { foreach ($indexes as $index) { $moduleMenu[$index]['parent_menu'] = $parentName; } } }