/**
  * Parse list of icons and get pure icon names.
  *
  * @return array
  */
 protected function parseListOfIcons()
 {
     $cache = $this->cacheManager->getCache('Default');
     $cacheId = 'FontIconDataSource_parseListOfIcons';
     if (!($icons = $cache->get($cacheId))) {
         $icons = [];
         foreach (file(self::$iconsListFilePath) as $content) {
             if (preg_match('#fa-var-([-_a-z0-9]+):#i', $content, $match)) {
                 $icons[] = $match[1];
             }
         }
         $cache->set($cacheId, $icons, [], 0);
     }
     return $icons;
 }
 /**
  * @param $fileMonitorIdentifier
  * @param array $changedFiles
  * @return void
  */
 public function flushContentCacheOnFileChanges($fileMonitorIdentifier, array $changedFiles)
 {
     $fileMonitorsThatTriggerContentCacheFlush = array('TYPO3CR_NodeTypesConfiguration', 'TypoScript_Files', 'Fluid_TemplateFiles', 'Flow_ClassFiles', 'Flow_ConfigurationFiles', 'Flow_TranslationFiles');
     if (in_array($fileMonitorIdentifier, $fileMonitorsThatTriggerContentCacheFlush)) {
         $this->flowCacheManager->getCache('TYPO3_TypoScript_Content')->flush();
     }
 }
 /**
  * Initializes the controller before invoking an action method.
  *
  */
 public function initializeAction()
 {
     if ($this->securityContext->canBeInitialized()) {
         $account = $this->securityContext->getAccount();
         $this->bearbeiterObj = $this->bearbeiterRepository->findOneByAccount($account);
     }
     $this->cacheInterface = $this->cacheManager->getCache('GermaniaSacra_GermaniaCache');
 }
 /**
  * @param LifecycleEventArgs $eventArgs
  * @return void
  */
 public function postRemove(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if ($entity instanceof ImageInterface) {
         /** @var PersistentResource $resource */
         $resource = $eventArgs->getEntity()->getResource();
         if ($resource !== null) {
             $this->cacheManager->getCache('TYPO3_Media_ImageSize')->remove($resource->getCacheEntryIdentifier());
         }
     }
 }
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory.
  *
  * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache The cache frontend
  * @return void
  * @throws \TYPO3\Flow\Cache\Exception
  */
 public function setCache(FrontendInterface $cache)
 {
     parent::setCache($cache);
     $cacheDirectory = $this->cacheDirectory;
     if ($cacheDirectory == '') {
         $codeOrData = $cache instanceof PhpFrontend ? 'Code' : 'Data';
         $baseDirectory = $this->cacheManager->isCachePersistent($cache->getIdentifier()) ? FLOW_PATH_DATA . 'Persistent/' : $this->environment->getPathToTemporaryDirectory();
         $cacheDirectory = $baseDirectory . 'Cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
     }
     if (!is_writable($cacheDirectory)) {
         try {
             \TYPO3\Flow\Utility\Files::createDirectoryRecursively($cacheDirectory);
         } catch (\TYPO3\Flow\Utility\Exception $exception) {
             throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" could not be created.', 1264426237);
         }
     }
     if (!is_dir($cacheDirectory) && !is_link($cacheDirectory)) {
         throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" does not exist.', 1203965199);
     }
     if (!is_writable($cacheDirectory)) {
         throw new \TYPO3\Flow\Cache\Exception('The cache directory "' . $cacheDirectory . '" is not writable.', 1203965200);
     }
     $this->cacheDirectory = $cacheDirectory;
     $this->cacheEntryFileExtension = $cache instanceof PhpFrontend ? '.php' : '';
     if (strlen($this->cacheDirectory) + 23 > $this->environment->getMaximumPathLength()) {
         throw new \TYPO3\Flow\Cache\Exception('The length of the temporary cache path "' . $this->cacheDirectory . '" exceeds the maximum path length of ' . ($this->environment->getMaximumPathLength() - 23) . '. Please consider setting the temporaryDirectoryBase option to a shorter path. ', 1248710426);
     }
 }
 /**
  * Explicitly compile proxy classes
  *
  * The compile command triggers the proxy class compilation.
  * Although a compilation run is triggered automatically by Flow, there might
  * be cases in a production context where a manual compile run is needed.
  *
  * @Flow\Internal
  * @param boolean $force If set, classes will be compiled even though the cache says that everything is up to date.
  * @return void
  */
 public function compileCommand($force = false)
 {
     /** @var VariableFrontend $objectConfigurationCache */
     $objectConfigurationCache = $this->cacheManager->getCache('Flow_Object_Configuration');
     if ($force === false) {
         if ($objectConfigurationCache->has('allCompiledCodeUpToDate')) {
             return;
         }
     }
     /** @var PhpFrontend $classesCache */
     $classesCache = $this->cacheManager->getCache('Flow_Object_Classes');
     $this->proxyClassCompiler->injectClassesCache($classesCache);
     $this->aopProxyClassBuilder->injectObjectConfigurationCache($objectConfigurationCache);
     $this->aopProxyClassBuilder->build();
     $this->dependencyInjectionProxyClassBuilder->build();
     $classCount = $this->proxyClassCompiler->compile();
     $dataTemporaryPath = $this->environment->getPathToTemporaryDirectory();
     Files::createDirectoryRecursively($dataTemporaryPath);
     file_put_contents($dataTemporaryPath . 'AvailableProxyClasses.php', $this->proxyClassCompiler->getStoredProxyClassMap());
     $objectConfigurationCache->set('allCompiledCodeUpToDate', true);
     $classesCacheBackend = $classesCache->getBackend();
     if ($this->bootstrap->getContext()->isProduction() && $classesCacheBackend instanceof FreezableBackendInterface) {
         /** @var FreezableBackendInterface $backend */
         $backend = $classesCache->getBackend();
         $backend->freeze();
     }
     $this->emitFinishedCompilationRun($classCount);
 }
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory.
  *
  * @param \TYPO3\Flow\Cache\Frontend\FrontendInterface $cache The cache frontend
  * @return void
  * @throws Exception
  */
 public function setCache(FrontendInterface $cache)
 {
     parent::setCache($cache);
     $cacheDirectory = $this->cacheDirectory;
     if ($cacheDirectory == '') {
         $codeOrData = $cache instanceof PhpFrontend ? 'Code' : 'Data';
         $baseDirectory = $this->cacheManager->isCachePersistent($cache->getIdentifier()) ? FLOW_PATH_DATA . 'Persistent/' : $this->environment->getPathToTemporaryDirectory();
         $cacheDirectory = $baseDirectory . 'Cache/' . $codeOrData . '/' . $this->cacheIdentifier . '/';
     }
     if (!is_writable($cacheDirectory)) {
         try {
             \TYPO3\Flow\Utility\Files::createDirectoryRecursively($cacheDirectory);
         } catch (\TYPO3\Flow\Utility\Exception $exception) {
             throw new Exception('The cache directory "' . $cacheDirectory . '" could not be created.', 1264426237);
         }
     }
     if (!is_dir($cacheDirectory) && !is_link($cacheDirectory)) {
         throw new Exception('The cache directory "' . $cacheDirectory . '" does not exist.', 1203965199);
     }
     if (!is_writable($cacheDirectory)) {
         throw new Exception('The cache directory "' . $cacheDirectory . '" is not writable.', 1203965200);
     }
     $this->cacheDirectory = $cacheDirectory;
     $this->cacheEntryFileExtension = $cache instanceof PhpFrontend ? '.php' : '';
 }
 /**
  * @test
  */
 public function flushSystemCachesByChangedFilesFlushesI18nCacheIfATranslationFileHasBeenModified()
 {
     $this->registerCache('Flow_Object_Classes');
     $this->registerCache('Flow_Object_Configuration');
     $i18nCache = $this->registerCache('Flow_I18n_XmlModelCache');
     $i18nCache->expects($this->once())->method('flush');
     $this->cacheManager->flushSystemCachesByChangedFiles('Flow_TranslationFiles', array('Some/Other/File' => ChangeDetectionStrategyInterface::STATUS_CHANGED, 'Some/Package/Resources/Private/Translations/en/Foo.xlf' => ChangeDetectionStrategyInterface::STATUS_CHANGED));
 }
 /**
  * This aspect will reset the node type cache after changes to the dynamic node types
  *
  * @Flow\After("method(Shel\DynamicNodes\Controller\DynamicNodeTypeController->(update|create|delete|editProperty|createDynamicProperty|updateDynamicProperty|deleteDynamicProperty)Action())")
  * @param JoinPointInterface $joinPoint The current join point
  * @return void
  */
 public function clearNodeTypeConfigurationCache(JoinPointInterface $joinPoint)
 {
     // Flush note type configuration cache
     $this->nodeTypeManager->overrideNodeTypes(array());
     // Flush configuration version cache to force reload the node type schema
     $this->cacheManager->getCache('TYPO3_Neos_Configuration_Version')->flush();
     // Flush content cache so changed dynamic nodes are updated
     $this->cacheManager->getCache('TYPO3_TypoScript_Content')->flush();
 }
 /**
  * Makes sure that the AOP proxies are rebuilt if a policy has changed.
  *
  * Note: This is not an advice but a method which is used as a slot for a signal
  *       sent by the system file monitor defined in the bootstrap scripts.
  *
  * @param string $fileMonitorIdentifier Identifier of the File Monitor
  * @param array $changedFiles A list of full paths to changed files
  * @return void
  */
 public function triggerAopProxyRebuildingByChangedFiles($fileMonitorIdentifier, array $changedFiles)
 {
     if ($fileMonitorIdentifier !== 'Flow_PolicyFiles') {
         return;
     }
     $this->systemLogger->log('The security policies have changed, thus triggering an AOP proxy class rebuild.', LOG_INFO);
     $this->flushCachesByTag(\TYPO3\Flow\Cache\CacheManager::getClassTag());
     $this->flushCachesByTag(\TYPO3\Flow\Cache\CacheManager::getClassTag('TYPO3\\Flow\\Security\\Aspect\\PolicyEnforcementAspect'));
 }
 /**
  * @test
  */
 public function aDifferentDefaultCacheDirectoryIsUsedForPersistentCaches()
 {
     $this->mockCacheManager->expects($this->atLeastOnce())->method('isCachePersistent')->will($this->returnValue(true));
     $this->mockCacheFrontend->expects($this->any())->method('getIdentifier')->will($this->returnValue('SomeCache'));
     // We need to create the directory here because vfs doesn't support touch() which is used by
     // createDirectoryRecursively() in the setCache method.
     mkdir('vfs://Temporary/Directory/Cache');
     $simpleFileBackend = $this->getSimpleFileBackend();
     $this->assertEquals(FLOW_PATH_DATA . 'Persistent/Cache/Data/SomeCache/', $simpleFileBackend->getCacheDirectory());
 }
 /**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheObjectName Object name of the cache frontend
  * @param string $backendObjectName Object name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @return \TYPO3\Flow\Cache\Frontend\FrontendInterface The created cache frontend
  * @throws \TYPO3\Flow\Cache\Exception\InvalidBackendException
  * @throws \TYPO3\Flow\Cache\Exception\InvalidCacheException
  * @api
  */
 public function create($cacheIdentifier, $cacheObjectName, $backendObjectName, array $backendOptions = array())
 {
     $backend = new $backendObjectName($this->context, $backendOptions);
     if (!$backend instanceof \TYPO3\Flow\Cache\Backend\BackendInterface) {
         throw new \TYPO3\Flow\Cache\Exception\InvalidBackendException('"' . $backendObjectName . '" is not a valid cache backend object.', 1216304301);
     }
     $backend->injectEnvironment($this->environment);
     if (is_callable(array($backend, 'initializeObject'))) {
         $backend->initializeObject(\TYPO3\Flow\Object\ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     $cache = new $cacheObjectName($cacheIdentifier, $backend);
     if (!$cache instanceof \TYPO3\Flow\Cache\Frontend\FrontendInterface) {
         throw new \TYPO3\Flow\Cache\Exception\InvalidCacheException('"' . $cacheObjectName . '" is not a valid cache frontend object.', 1216304300);
     }
     if (is_callable(array($cache, 'initializeObject'))) {
         $cache->initializeObject(\TYPO3\Flow\Object\ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     $this->cacheManager->registerCache($cache);
     return $cache;
 }
 /**
  * Call system function
  *
  * @Flow\Internal
  * @param integer $address
  * @return void
  */
 public function sysCommand($address)
 {
     if ($address === 64738) {
         $this->cacheManager->flushCaches();
         $content = 'G1syShtbMkobWzE7MzdtG1sxOzQ0bSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtICAgICAgKioqKiBDT01NT0RPUkUgNjQgQkFTSUMgVjIgKioqKiAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gIDY0SyBSQU0gU1lTVEVNICAzODkxMSBCQVNJQyBCWVRFUyBGUkVFICAgG1swbQobWzE7MzdtG1sxOzQ0bSBSRUFEWS4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtIEZMVVNIIENBQ0hFICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1swbQobWzE7MzdtG1sxOzQ0bSBPSywgRkxVU0hFRCBBTEwgQ0FDSEVTLiAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtIFJFQURZLiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gG1sxOzQ3bSAbWzE7NDRtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1swbQobWzE7MzdtG1sxOzQ0bSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1swbQobWzE7MzdtG1sxOzQ0bSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAbWzBtChtbMTszN20bWzE7NDRtICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIBtbMG0KG1sxOzM3bRtbMTs0NG0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgG1swbQoK';
         $this->response->setOutputFormat(Response::OUTPUTFORMAT_RAW);
         $this->response->appendContent(base64_decode($content));
         if ($this->lockManager->isSiteLocked()) {
             $this->lockManager->unlockSite();
         }
         $this->sendAndExit(0);
     }
 }
 /**
  * @test
  */
 public function createRegistersTheCacheAtTheCacheManager()
 {
     $cacheManager = new CacheManager();
     $factory = new CacheFactory(new ApplicationContext('Testing'), $cacheManager, $this->mockEnvironment);
     $this->assertFalse($cacheManager->hasCache('TYPO3_Flow_Cache_FactoryTest_Cache'));
     $factory->create('TYPO3_Flow_Cache_FactoryTest_Cache', \TYPO3\Flow\Cache\Frontend\VariableFrontend::class, \TYPO3\Flow\Cache\Backend\FileBackend::class);
     $this->assertTrue($cacheManager->hasCache('TYPO3_Flow_Cache_FactoryTest_Cache'));
     $this->assertFalse($cacheManager->isCachePersistent('TYPO3_Flow_Cache_FactoryTest_Cache'));
     $this->assertFalse($cacheManager->hasCache('Persistent_Cache'));
     $factory->create('Persistent_Cache', \TYPO3\Flow\Cache\Frontend\VariableFrontend::class, \TYPO3\Flow\Cache\Backend\FileBackend::class, array(), true);
     $this->assertTrue($cacheManager->hasCache('Persistent_Cache'));
     $this->assertTrue($cacheManager->isCachePersistent('Persistent_Cache'));
 }
 /**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheObjectName Object name of the cache frontend
  * @param string $backendObjectName Object name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @param boolean $persistent If the new cache should be marked as "persistent"
  * @return Frontend\FrontendInterface The created cache frontend
  * @throws Exception\InvalidBackendException
  * @throws Exception\InvalidCacheException
  * @api
  */
 public function create($cacheIdentifier, $cacheObjectName, $backendObjectName, array $backendOptions = [], $persistent = false)
 {
     $backend = new $backendObjectName($this->context, $backendOptions);
     if (!$backend instanceof Backend\BackendInterface) {
         throw new Exception\InvalidBackendException('"' . $backendObjectName . '" is not a valid cache backend object.', 1216304301);
     }
     $backend->injectEnvironment($this->environment);
     if (is_callable([$backend, 'injectCacheManager'])) {
         $backend->injectCacheManager($this->cacheManager);
     }
     if (is_callable([$backend, 'initializeObject'])) {
         $backend->initializeObject(ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     $cache = new $cacheObjectName($cacheIdentifier, $backend);
     if (!$cache instanceof Frontend\FrontendInterface) {
         throw new Exception\InvalidCacheException('"' . $cacheObjectName . '" is not a valid cache frontend object.', 1216304300);
     }
     $this->cacheManager->registerCache($cache, $persistent);
     if (is_callable([$cache, 'initializeObject'])) {
         $cache->initializeObject(ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     return $cache;
 }
 /**
  * Initializes the cache framework
  *
  * @param Bootstrap $bootstrap
  * @return void
  */
 public static function initializeCacheManagement(Bootstrap $bootstrap)
 {
     $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
     $environment = $bootstrap->getEarlyInstance(Environment::class);
     $cacheManager = new CacheManager();
     $cacheManager->setCacheConfigurations($configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_CACHES));
     $cacheManager->injectConfigurationManager($configurationManager);
     $cacheManager->injectSystemLogger($bootstrap->getEarlyInstance(SystemLoggerInterface::class));
     $cacheManager->injectEnvironment($environment);
     $cacheFactory = new CacheFactory($bootstrap->getContext(), $cacheManager, $environment);
     $bootstrap->setEarlyInstance(CacheManager::class, $cacheManager);
     $bootstrap->setEarlyInstance(CacheFactory::class, $cacheFactory);
 }
 /**
  * Injects the Cache Manager because we cannot inject an automatically factored cache during compile time.
  *
  * @param CacheManager $cacheManager
  * @return void
  */
 public function injectCacheManager(CacheManager $cacheManager)
 {
     $this->methodPermissionCache = $cacheManager->getCache('Flow_Security_Authorization_Privilege_Method');
 }
 /**
  * @test
  */
 public function getClassTagRendersTagWhichCanBeUsedToTagACacheEntryWithACertainClass()
 {
     $identifier = 'someCacheIdentifier';
     $backend = $this->getMock(\TYPO3\Flow\Cache\Backend\AbstractBackend::class, array('get', 'set', 'has', 'remove', 'findIdentifiersByTag', 'flush', 'flushByTag', 'collectGarbage'), array(), '', false);
     $this->getMock(\TYPO3\Flow\Cache\Frontend\StringFrontend::class, array('__construct', 'get', 'set', 'has', 'remove', 'getByTag'), array($identifier, $backend));
     $this->assertEquals('%CLASS%TYPO3_Foo_Bar_Baz', \TYPO3\Flow\Cache\CacheManager::getClassTag('TYPO3\\Foo\\Bar\\Baz'));
 }
 /**
  * Create a new user
  *
  * @param string $cacheIdentifier
  * @Flow\Validate(argumentName="cacheIdentifier", type="\TYPO3\Flow\Validation\Validator\NotEmptyValidator")
  * @return void
  */
 public function flushAction($cacheIdentifier)
 {
     $this->cacheManager->getCache($cacheIdentifier)->flush();
     $this->addFlashMessage('Successfully flushed the cache "%s".', 'User created', Message::SEVERITY_OK, [$cacheIdentifier], 1448033946);
     $this->redirect('index');
 }
 /**
  * Injects the Cache Manager because we cannot inject an automatically factored cache during compile time.
  *
  * @param CacheManager $cacheManager
  * @return void
  */
 public function injectCacheManager(CacheManager $cacheManager)
 {
     $this->policyCache = $cacheManager->getCache('Flow_Security_Policy');
 }
 /**
  * Flushes entries tagged by the specified tag of all registered
  * caches.
  *
  * @param mixed $objectOrCacheTag
  */
 public function flushCachesByTag($objectOrCacheTag)
 {
     foreach ($this->createCacheTags($objectOrCacheTag) as $tag) {
         $this->cacheManager->flushCachesByTag($tag);
     }
 }
 /**
  * @return void
  */
 protected function flushConfigurationCache()
 {
     $this->cacheManager->getCache('TYPO3_Neos_Configuration_Version')->flush();
 }
 /**
  * Injects the Cache Manager because we cannot inject an automatically factored cache during compile time.
  *
  * @param \TYPO3\Flow\Cache\CacheManager $cacheManager
  * @return void
  */
 public function injectCacheManager(\TYPO3\Flow\Cache\CacheManager $cacheManager)
 {
     $this->cache = $cacheManager->getCache('Flow_Security_Policy');
 }
 /**
  * @test
  */
 public function getClassTagRendersTagWhichCanBeUsedToTagACacheEntryWithACertainClass()
 {
     $this->assertEquals('%CLASS%TYPO3_Foo_Bar_Baz', \TYPO3\Flow\Cache\CacheManager::getClassTag('TYPO3\\Foo\\Bar\\Baz'));
 }