1
0
mirror of synced 2024-12-01 17:56:07 +03:00
bitrix-module/intaro.retailcrm/lib/component/dependencyloader.php
Neur0toxine 5f69051859
Программа лояльности
* New module structure (refactoring)
* Simple serializer and deserializer with models, new architecture
* Move logic to strategies
* Partial api client facade implementation (full implementation is not necessary for now)
* Loyalty feature installer
* Sms verification order (#167)
* Make updater self-sufficient
* Fix for order submit & fix for incorrect component rendering in the constructor
* Fix for loyalty personal area error handling
* Fix for cart component identity
* Fix for softlock when customer cannot be registered in loyalty

Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com>
Co-authored-by: Sergey Chazov <oitv18@gmail.com>
2021-11-16 10:48:26 +03:00

101 lines
2.5 KiB
PHP

<?php
/**
* PHP version 7.1
*
* @category Integration
* @package Intaro\RetailCrm\Component
* @author RetailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
namespace Intaro\RetailCrm\Component;
use CModule;
use RCrmActions;
/**
* Class DependencyLoader
*
* @package Intaro\RetailCrm\Component
*/
class DependencyLoader
{
/** @var int */
const LEGACY_LOADER = 0;
/** @var int */
const D7_LOADER = 1;
/** @var int $loader */
private static $loader = self::D7_LOADER;
/**
* Loads dependencies
*
* @return bool
*/
public static function loadDependencies()
{
foreach (self::getDependencies() as $dependency) {
if (self::LEGACY_LOADER == self::$loader) {
if (!CModule::IncludeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} else {
try {
if (!\Bitrix\Main\Loader::includeModule($dependency)) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
'module not found'
);
return false;
}
} catch (\Bitrix\Main\LoaderException $exception) {
RCrmActions::eventLog(
__CLASS__ . '::' . __METHOD__,
$dependency,
sprintf('error while trying to load module: %s', $exception->getMessage())
);
return false;
}
}
}
return true;
}
/**
* Set loader mode. Use RetailcrmDependencyLoader::LEGACY_LOADER or RetailcrmDependencyLoader::D7_LOADER
*
* @param $loader
*/
public static function setLoader($loader)
{
if (in_array($loader, array(self::LEGACY_LOADER, self::D7_LOADER))) {
self::$loader = $loader;
}
}
/**
* Returns array of required modules names
*
* @return array<string>
*/
public static function getDependencies()
{
return array("iblock", "sale", "catalog");
}
}