Last active
March 22, 2019 10:36
-
-
Save AndreySkryl/ad211f2584182be29d030a47afe36644 to your computer and use it in GitHub Desktop.
(Bitrix24) Класс "Валидатор зависимостей модуля"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| /** | |
| * класс "Валидатор зависимостей модуля" | |
| */ | |
| class ModuleDependencyValidator { | |
| /** | |
| * Проверка зависимостей | |
| * @param array $dependencies Массив зависимостей (модулей), необходимых для работы конкретного [класса, ...] | |
| * @return bool $result Результат валидации | |
| * | |
| * @throws \Exception $exception Исключение с сообщением "Модуль (зависимость) '".$dependency."' не найдена." | |
| */ | |
| public static function validate(array $dependencies = ["iblock"]) { | |
| foreach ($dependencies as $dependency) { | |
| $dependency = trim(strtolower($dependency)); | |
| if (!\Bitrix\Main\Loader::includeModule($dependency)) { | |
| $message = str_replace(["#FIELD_NAME#"], [$dependency], Loc::getMessage("DEPENDENCY_IS_NOT_FOUND")); | |
| throw new \Exception($message); | |
| } | |
| } | |
| return true; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment