コード例 #1
0
 public function get($name)
 {
     if (isset($this->tools[$name]) && count($this->tools[$name]) > 0) {
         $obj = $this->tools[$name][0];
         if (is_object($obj)) {
             return $obj;
         } elseif (is_string($obj) && class_exists($obj)) {
             $this->tools[$name][0] = new $obj();
             return $this->tools[$name][0];
         } elseif (is_array($obj) && isset($obj[0]) && isset($obj[1]) && is_string($obj[0]) && is_string($obj[1])) {
             if (Loader::includeModule($obj[0]) && class_exists($obj[1])) {
                 $this->tools[$name][0] = new $obj[1]();
                 return $this->tools[$name][0];
             }
             throw new LoaderException(sprintf("Class name '%s' is not found in module '%s'", htmlspecialchars($obj[1]), htmlspecialchars($obj[0])));
         }
         throw new SystemException(sprintf("Tool '%s' is not found", htmlspecialchars($obj)));
     }
     return null;
 }
コード例 #2
0
 private function sendToEventHandler(array $handler, Event $event)
 {
     try {
         $result = true;
         $event->addDebugInfo($handler);
         if (isset($handler["MODULE_ID"]) && !empty($handler["MODULE_ID"])) {
             $result = Loader::includeModule($handler["MODULE_ID"]);
         } elseif (isset($handler["PATH"]) && !empty($handler["PATH"])) {
             $path = ltrim($handler["PATH"], "/");
             if ($path = Loader::getLocal($path)) {
                 $result = (include_once $path);
             }
         } elseif (isset($handler["INCLUDE_FILE"]) && !empty($handler["INCLUDE_FILE"]) && \Bitrix\Main\IO\File::isFileExists($handler["INCLUDE_FILE"])) {
             $result = (include_once $handler["INCLUDE_FILE"]);
         }
         $event->addDebugInfo($result);
         if (isset($handler["METHOD_ARG"]) && is_array($handler["METHOD_ARG"]) && count($handler["METHOD_ARG"])) {
             $args = $handler["METHOD_ARG"];
         } else {
             $args = array();
         }
         if ($handler["VERSION"] > 1) {
             $args[] = $event;
         } else {
             $args = array_merge($args, array_values($event->getParameters()));
         }
         $callback = null;
         if (array_key_exists("CALLBACK", $handler)) {
             $callback = $handler["CALLBACK"];
         } elseif (!empty($handler["CLASS"]) && !empty($handler["METHOD"]) && class_exists($handler["CLASS"])) {
             $callback = array($handler["CLASS"], $handler["METHOD"]);
         }
         if ($callback != null) {
             $result = call_user_func_array($callback, $args);
         }
         if ($result != null && !$result instanceof EventResult) {
             $result = new EventResult(EventResult::UNDEFINED, $result, $handler["MODULE_ID"]);
         }
         $event->addDebugInfo($result);
         if ($result != null) {
             $event->addResult($result);
         }
     } catch (\Exception $ex) {
         if ($event->isDebugOn()) {
             $event->addException($ex);
         } else {
             throw $ex;
         }
     }
 }
コード例 #3
0
ファイル: cache.php プロジェクト: VitaliiSestrenskyi/sest
$isVerticalFilter = 'Y' == $arParams['USE_FILTER'] && $arParams["FILTER_VIEW_MODE"] == "VERTICAL";
$isSidebar = $arParams["SIDEBAR_SECTION_SHOW"] == "Y" && isset($arParams["SIDEBAR_PATH"]) && !empty($arParams["SIDEBAR_PATH"]);
$isFilter = $arParams['USE_FILTER'] == 'Y';
if ($isFilter) {
    $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "ACTIVE" => "Y", "GLOBAL_ACTIVE" => "Y");
    if (0 < intval($arResult["VARIABLES"]["SECTION_ID"])) {
        $arFilter["ID"] = $arResult["VARIABLES"]["SECTION_ID"];
    } elseif ('' != $arResult["VARIABLES"]["SECTION_CODE"]) {
        $arFilter["=CODE"] = $arResult["VARIABLES"]["SECTION_CODE"];
    }
    $obCache = new CPHPCache();
    if ($obCache->InitCache(36000, serialize($arFilter), "/iblock/catalog")) {
        $arCurSection = $obCache->GetVars();
    } elseif ($obCache->StartDataCache()) {
        $arCurSection = array();
        if (Loader::includeModule("iblock")) {
            $dbRes = CIBlockSection::GetList(array(), $arFilter, false, array("ID"));
            if (defined("BX_COMP_MANAGED_CACHE")) {
                global $CACHE_MANAGER;
                $CACHE_MANAGER->StartTagCache("/iblock/catalog");
                if ($arCurSection = $dbRes->Fetch()) {
                    $CACHE_MANAGER->RegisterTag("iblock_id_" . $arParams["IBLOCK_ID"]);
                }
                $CACHE_MANAGER->EndTagCache();
            } else {
                if (!($arCurSection = $dbRes->Fetch())) {
                    $arCurSection = array();
                }
            }
        }
        $obCache->EndDataCache($arCurSection);