public static function loadIncludeCache() { $oStrategy = CachingStrategyFile::create(); self::$INCLUDE_CACHE = new Cache(self::CACHE_KEY, DIRNAME_PRELOAD, $oStrategy); self::$MAPPING_HAS_BEEN_MODIFIED = false; if (!self::$INCLUDE_CACHE->entryExists()) { self::$CLASS_MAPPING = array(); return; } self::$CLASS_MAPPING = self::$INCLUDE_CACHE->getContentsAsVariable(); }
public static function getInstance($sFile = null) { if ($sFile === null) { $sFile = "config"; } $sCacheKey = self::createCacheKey($sFile); $sFileName = "{$sFile}.yml"; if (!isset(self::$INSTANCES[$sCacheKey])) { $oCache = new Cache($sCacheKey, DIRNAME_CONFIG, CachingStrategyFile::create()); $oFinder = ResourceFinder::create(array(DIRNAME_CONFIG))->addOptionalPath(ErrorHandler::getEnvironment())->addPath($sFileName)->byExpressions()->searchBaseFirst()->all(); if ($oCache->entryExists() && !$oCache->isOutdated($oFinder)) { self::$INSTANCES[$sCacheKey] = $oCache->getContentsAsVariable(); } else { self::$INSTANCES[$sCacheKey] = new Settings($oFinder, $sFile); $oCache->setContents(self::$INSTANCES[$sCacheKey]); } } return self::$INSTANCES[$sCacheKey]; }
public static function allParts() { $oCache = new Cache("system_parts", DIRNAME_CONFIG, CachingStrategyFile::create()); if ($oCache->entryExists()) { return $oCache->getContentsAsVariable(); } $oBasePart = new BasePart(); $oSitePart = new SitePart(); $aParts = array(DIRNAME_BASE => $oBasePart); // Get all plugins foreach (ResourceFinder::pluginFinder()->returnObjects()->find() as $oPath) { $oPluginPart = SystemPart::getPart($oPath->getRelativePath()); // Plugins depend on base implicitly $oPluginPart->dependOn($oBasePart); // Site depends on plugins implicitly $oSitePart->dependOn($oPluginPart); $aParts[$oPath->getRelativePath()] = $oPluginPart; } $oSitePart->dependOn($oBasePart); $aParts[DIRNAME_SITE] = $oSitePart; // Add dependencies from info foreach ($aParts as $oPart) { $aInfo = $oPart->getInfo(); foreach ($aInfo['dependencies'] as $sDependencyPrefix => $sVersion) { if (isset($aParts[$sDependencyPrefix])) { $oPart->dependOn($aParts[$sDependencyPrefix]); } else { throw new Exception("Dependency of {$oPart->getPrefix()} on {$sDependencyPrefix} can not be satisfied"); } } foreach ($aInfo['optional_dependencies'] as $sDependencyPrefix => $sVersion) { if (isset($aParts[$sDependencyPrefix])) { $oPart->dependOn($aParts[$sDependencyPrefix]); } } } // Order list by dependencies $aParts = self::orderedParts($aParts); // Cache ordered list $oCache->setContents($aParts); return $aParts; }
/** * @return bool|string|FileResource|array the matched path(s) */ public function find() { if ($this->mResult === false) { if (!$this->bNoCache && ErrorHandler::isProduction()) { $oCache = new Cache(serialize($this), 'resource_finder', CachingStrategyFile::create()); if ($oCache->entryExists()) { $this->mResult = $oCache->getContentsAsVariable(); } else { $this->mResult = $this->doFind(); $oCache->setContents($this->mResult, true); } } else { $this->mResult = $this->doFind(); } } return $this->mResult; }