public function reBuild() { $classPath = 'Classes/'; foreach ($GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes'] as $key => $extensionsWithThisClass) { $extendingClassFound = false; $path = ExtensionManagementUtility::extPath('news') . $classPath . $key . '.php'; if (!is_file($path)) { throw new \Exception('Given file "' . $path . '" does not exist'); } $code = $this->parseSingleFile($path, true); // Get the files from all other extensions foreach ($extensionsWithThisClass as $extensionKey) { $path = ExtensionManagementUtility::extPath($extensionKey) . $classPath . $key . '.php'; if (is_file($path)) { $extendingClassFound = true; $code .= $this->parseSingleFile($path, false); } } $code = $this->closeClassDefinition($code); // If an extending class is found, the file is written and // added to the autoloader info if ($extendingClassFound) { $cacheEntryIdentifier = 'tx_news_' . strtolower(str_replace('/', '_', $key)); try { $this->cacheInstance->set($cacheEntryIdentifier, $code); } catch (\Exception $e) { throw new \Exception($e->getMessage()); } } } }
/** * Rebuild the class cache * * @param array $parameters * * @throws \Evoweb\Extender\Exception\FileNotFoundException * @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException * @return void */ public function reBuild(array $parameters = array()) { if (empty($parameters) || !empty($parameters['cacheCmd']) && GeneralUtility::inList('all,system', $parameters['cacheCmd']) && isset($GLOBALS['BE_USER'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] as $extensionKey => $extensionConfiguration) { if (!isset($extensionConfiguration['extender']) || !is_array($extensionConfiguration['extender'])) { continue; } foreach ($extensionConfiguration['extender'] as $entity => $entityConfiguration) { $key = 'Domain/Model/' . $entity; // Get the file to extend, this needs to be loaded as first $path = ExtensionManagementUtility::extPath($extensionKey) . 'Classes/' . $key . '.php'; if (!is_file($path)) { throw new \Evoweb\Extender\Exception\FileNotFoundException('given file "' . $path . '" does not exist'); } $code = $this->parseSingleFile($path, false); // Get the files from all other extensions that are extending this domain model if (is_array($entityConfiguration)) { foreach ($entityConfiguration as $extendingExtension => $extendingFilepath) { $path = GeneralUtility::getFileAbsFileName($extendingFilepath, false); if (!is_file($path) && !is_numeric($extendingExtension)) { $path = ExtensionManagementUtility::extPath($extendingExtension) . 'Classes/' . $key . '.php'; } $code .= $this->parseSingleFile($path); } } // Close the class definition $code = $this->closeClassDefinition($code); // Add the new file to the class cache $cacheEntryIdentifier = GeneralUtility::underscoredToLowerCamelCase($extensionKey) . '_' . str_replace('/', '', $key); $this->cacheInstance->set($cacheEntryIdentifier, $code); } } } }
/** * Save package namespaces and classes paths to cache * * @return void */ protected function savePackageNamespacesAndClassesPathsToCache() { $cacheEntryIdentifier = $this->getCacheEntryIdentifier(); if ($cacheEntryIdentifier !== NULL) { $this->coreCache->set($this->getCacheEntryIdentifier(), 'return ' . var_export(array($this->packageNamespaces, $this->packageClassesPaths), TRUE) . ';'); } }
/** * @param string $entryIdentifier * @param string $sourceCode * @param array $tags * @param int $lifetime * @throws InvalidDataException */ public function set($entryIdentifier, $sourceCode, array $tags = array(), $lifetime = null) { if (strpos($sourceCode, '<?php') === 0) { // Remove opening PHP tag; it is added by the cache backend to which // we delegate and would be duplicated if not removed. $sourceCode = substr($sourceCode, 6); } parent::set($entryIdentifier, $sourceCode, $tags, time() + 86400); }
/** * Attempts to load the package manager states from cache * * @throws Exception\PackageManagerCacheUnavailableException */ protected function loadPackageManagerStatesFromCache() { $cacheEntryIdentifier = $this->getCacheEntryIdentifier(); if ($cacheEntryIdentifier === null || !$this->coreCache->has($cacheEntryIdentifier) || !($packageCache = $this->coreCache->requireOnce($cacheEntryIdentifier))) { throw new Exception\PackageManagerCacheUnavailableException('The package state cache could not be loaded.', 1393883342); } $this->packageStatesConfiguration = $packageCache['packageStatesConfiguration']; $this->packageAliasMap = $packageCache['packageAliasMap']; $this->composerNameToPackageKeyMap = $packageCache['composerNameToPackageKeyMap']; $GLOBALS['TYPO3_LOADED_EXT'] = $packageCache['loadedExtArray']; $GLOBALS['TYPO3_currentPackageManager'] = $this; // Strip off PHP Tags from Php Cache Frontend $packageObjects = substr(substr($this->coreCache->get($packageCache['packageObjectsCacheEntryIdentifier']), 6), 0, -2); $this->packages = unserialize($packageObjects); foreach ($packageCache['activePackageKeys'] as $activePackageKey) { $this->activePackages[$activePackageKey] = $this->packages[$activePackageKey]; } unset($GLOBALS['TYPO3_currentPackageManager']); }
/** * @param string $identifier * @param \TYPO3\CMS\Fluid\Core\Parser\ParsingState $parsingState * @return void */ public function store($identifier, \TYPO3\CMS\Fluid\Core\Parser\ParsingState $parsingState) { $identifier = $this->sanitizeIdentifier($identifier); $this->variableCounter = 0; $generatedRenderFunctions = ''; if ($parsingState->getVariableContainer()->exists('sections')) { $sections = $parsingState->getVariableContainer()->get('sections'); // @todo refactor to $parsedTemplate->getSections() foreach ($sections as $sectionName => $sectionRootNode) { $generatedRenderFunctions .= $this->generateCodeForSection($this->convertListOfSubNodes($sectionRootNode), 'section_' . sha1($sectionName), 'section ' . $sectionName); } } $generatedRenderFunctions .= $this->generateCodeForSection($this->convertListOfSubNodes($parsingState->getRootNode()), 'render', 'Main Render function'); $convertedLayoutNameNode = $parsingState->hasLayout() ? $this->convert($parsingState->getLayoutNameNode()) : array('initialization' => '', 'execution' => 'NULL'); $classDefinition = 'class FluidCache_' . $identifier . ' extends \\TYPO3\\CMS\\Fluid\\Core\\Compiler\\AbstractCompiledTemplate'; $templateCode = <<<EOD %s { public function getVariableContainer() { \t// @todo \treturn new \\TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer(); } public function getLayoutName(\\TYPO3\\CMS\\Fluid\\Core\\Rendering\\RenderingContextInterface \$renderingContext) { \$currentVariableContainer = \$renderingContext->getTemplateVariableContainer(); %s return %s; } public function hasLayout() { return %s; } %s } EOD; $templateCode = sprintf($templateCode, $classDefinition, $convertedLayoutNameNode['initialization'], $convertedLayoutNameNode['execution'], $parsingState->hasLayout() ? 'TRUE' : 'FALSE', $generatedRenderFunctions); $this->templateCache->set($identifier, $templateCode); }
/** * Cleares the complete cache for class loader. * * @return void */ protected function clearClassesCache() { $this->coreCache->flush(); $this->classesCache->flush(); }