/** * Создает и возврашает объект типа * * @param string $sType * * @return bool|ModuleAsset_EntityType */ public function CreateObjectType($sType) { /** * Формируем имя класса для типа */ $sClass = "ModuleAsset_EntityType" . func_camelize($sType); if (class_exists(Engine::GetEntityClass($sClass))) { return Engine::GetEntity($sClass); } return false; }
/** * Возвращает объект бекенда кеша * * @param string|null $sCacheType Тип кеша * * @return ModuleCache_EntityBackend Объект бекенда кеша * @throws Exception */ protected function GetCacheBackend($sCacheType = null) { if ($sCacheType) { $sCacheType = strtolower($sCacheType); } else { $sCacheType = $this->sCacheType; } /** * Устанавливает алиас memory == memcached */ if ($sCacheType == 'memory') { $sCacheType = 'memcached'; } if (isset($this->aCacheBackends[$sCacheType])) { return $this->aCacheBackends[$sCacheType]; } $sCacheTypeCam = func_camelize($sCacheType); /** * Формируем имя класса бекенда */ $sClass = "ModuleCache_EntityBackend{$sCacheTypeCam}"; $sClass = Engine::GetEntityClass($sClass); if (class_exists($sClass)) { /** * Создаем объект и проверяем доступность его использования */ $oBackend = new $sClass(); if (true === ($mResult = $oBackend->IsAvailable())) { $oBackend->Init(array('stats_callback' => array($this, 'CalcStats'))); $this->aCacheBackends[$sCacheType] = $oBackend; return $oBackend; } else { throw new Exception("Cache '{$sCacheTypeCam}' not available: {$mResult}"); } } throw new Exception("Not found class for cache type: " . $sCacheTypeCam); }