Esempio n. 1
0
 /**
  * Caches the directories and their files
  *
  * @return void
  */
 public function shutdownObject()
 {
     if ($this->directoriesChanged === TRUE) {
         $this->cache->set($this->identifier . '_directoriesAndFiles', $this->directoriesAndFiles);
     }
     $this->changeDetectionStrategy->shutdownObject();
 }
Esempio n. 2
0
 /**
  * When it's called, XML file is parsed (using parser set in $xmlParser)
  * or cache is loaded, if available.
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->cache->has(md5($this->sourcePath))) {
         $this->xmlParsedData = $this->cache->get(md5($this->sourcePath));
     } else {
         $this->xmlParsedData = $this->xmlParser->getParsedData($this->sourcePath);
         $this->cache->set(md5($this->sourcePath), $this->xmlParsedData);
     }
 }
Esempio n. 3
0
 /**
  * Save the found matches to the cache.
  *
  * @return void
  */
 public function savePolicyCache()
 {
     $tags = array('TYPO3_FLOW3_Aop');
     if (!$this->cache->has('acls')) {
         $this->cache->set('acls', $this->acls, $tags);
     }
     if (!$this->cache->has('entityResourcesConstraints')) {
         $this->cache->set('entityResourcesConstraints', $this->entityResourcesConstraints);
     }
 }
Esempio n. 4
0
 /**
  * When it's called, CLDR file is parsed or cache is loaded, if available.
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->cache->has($this->cacheKey)) {
         $this->parsedData = $this->cache->get($this->cacheKey);
     } else {
         $this->parsedData = $this->parseFiles($this->sourcePaths);
         $this->parsedData = $this->resolveAliases($this->parsedData, '');
         $this->cache->set($this->cacheKey, $this->parsedData);
     }
 }
Esempio n. 5
0
 /**
  * Initializes this locale service
  *
  * @return void
  */
 public function initialize()
 {
     $this->configuration = new Configuration($this->settings['defaultLocale']);
     $this->configuration->setFallbackRule($this->settings['fallbackRule']);
     if ($this->cache->has('availableLocales')) {
         $this->localeCollection = $this->cache->get('availableLocales');
     } else {
         $this->generateAvailableLocalesCollectionByScanningFilesystem();
         $this->cache->set('availableLocales', $this->localeCollection);
     }
 }
Esempio n. 6
0
 /**
  * Constructs the reader, loading parsed data from cache if available.
  *
  * @return void
  */
 public function initializeObject()
 {
     if ($this->cache->has('rulesets') && $this->cache->has('rulesetsIndices')) {
         $this->rulesets = $this->cache->get('rulesets');
         $this->rulesetsIndices = $this->cache->get('rulesetsIndices');
     } else {
         $this->generateRulesets();
         $this->cache->set('rulesets', $this->rulesets);
         $this->cache->set('rulesetsIndices', $this->rulesetsIndices);
     }
 }
Esempio n. 7
0
 /**
  * Exports the internal reflection data into the ReflectionData cache
  *
  * This method is triggered by a signal which is connected to the bootstrap's
  * shutdown sequence.
  *
  * If the reflection data has previously been loaded from the runtime cache,
  * saving it is omitted as changes are not expected.
  *
  * In Production context the whole cache is written at once and then frozen in
  * order to be consistent. Frozen cache data in Development is only produced for
  * classes contained in frozen packages.
  *
  * @return void
  * @throws \TYPO3\FLOW3\Reflection\Exception if no cache has been injected
  */
 public function saveToCache()
 {
     if ($this->loadFromClassSchemaRuntimeCache === TRUE) {
         return;
     }
     if (!$this->reflectionDataCompiletimeCache instanceof \TYPO3\FLOW3\Cache\Frontend\FrontendInterface) {
         throw new \TYPO3\FLOW3\Reflection\Exception('A cache must be injected before initializing the Reflection Service.', 1232044697);
     }
     if (count($this->updatedReflectionData) > 0) {
         $this->log(sprintf('Found %s classes whose reflection data was not cached previously.', count($this->updatedReflectionData)), LOG_DEBUG);
         foreach (array_keys($this->updatedReflectionData) as $className) {
             $this->statusCache->set(str_replace('\\', '_', $className), '');
         }
         $data = array();
         $propertyNames = array('classReflectionData', 'classSchemata', 'annotatedClasses', 'classesByMethodAnnotations');
         foreach ($propertyNames as $propertyName) {
             $data[$propertyName] = $this->{$propertyName};
         }
         $this->reflectionDataCompiletimeCache->set('ReflectionData', $data);
     }
     if ($this->context->isProduction()) {
         $this->reflectionDataRuntimeCache->flush();
         $classNames = array();
         foreach ($this->classReflectionData as $className => $reflectionData) {
             $classNames[$className] = TRUE;
             $this->reflectionDataRuntimeCache->set(str_replace('\\', '_', $className), $reflectionData);
             if (isset($this->classSchemata[$className])) {
                 $this->classSchemataRuntimeCache->set(str_replace('\\', '_', $className), $this->classSchemata[$className]);
             }
         }
         $this->reflectionDataRuntimeCache->set('__classNames', $classNames);
         $this->reflectionDataRuntimeCache->set('__annotatedClasses', $this->annotatedClasses);
         $this->reflectionDataRuntimeCache->getBackend()->freeze();
         $this->classSchemataRuntimeCache->getBackend()->freeze();
         $this->log(sprintf('Built and froze reflection runtime caches (%s classes).', count($this->classReflectionData)), LOG_INFO);
     } elseif ($this->context->isDevelopment()) {
         foreach (array_keys($this->packageManager->getFrozenPackages()) as $packageKey) {
             $pathAndFilename = $this->getPrecompiledReflectionStoragePath() . $packageKey . '.dat';
             if (!file_exists($pathAndFilename)) {
                 $this->log(sprintf('Rebuilding precompiled reflection data for frozen package %s.', $packageKey), LOG_INFO);
                 $this->freezePackageReflection($packageKey);
             }
         }
     }
 }
Esempio n. 8
0
 /**
  * Builds the  objects array which contains information about the registered objects,
  * their scope, class, built method etc.
  *
  * @return array
  */
 protected function buildObjectsArray()
 {
     $objects = array();
     foreach ($this->objectConfigurations as $objectConfiguration) {
         $objectName = $objectConfiguration->getObjectName();
         $objects[$objectName] = array('l' => strtolower($objectName), 's' => $objectConfiguration->getScope(), 'p' => $objectConfiguration->getPackageKey());
         if ($objectConfiguration->getClassName() !== $objectName) {
             $objects[$objectName]['c'] = $objectConfiguration->getClassName();
         }
         if ($objectConfiguration->getFactoryObjectName() !== '') {
             $objects[$objectName]['f'] = array($objectConfiguration->getFactoryObjectName(), $objectConfiguration->getFactoryMethodName());
             $objects[$objectName]['fa'] = array();
             $factoryMethodArguments = $objectConfiguration->getArguments();
             if (count($factoryMethodArguments) > 0) {
                 foreach ($factoryMethodArguments as $index => $argument) {
                     $objects[$objectName]['fa'][$index] = array('t' => $argument->getType(), 'v' => $argument->getValue());
                 }
             }
         }
     }
     $this->configurationCache->set('objects', $objects);
     return $objects;
 }
Esempio n. 9
0
 /**
  * Builds proxy class code which weaves advices into the respective target classes.
  *
  * The object configurations provided by the Compiler are searched for possible aspect
  * annotations. If an aspect class is found, the poincut expressions are parsed and
  * a new aspect with one or more advisors is added to the aspect registry of the AOP framework.
  * Finally all advices are woven into their target classes by generating proxy classes.
  *
  * In general, the command typo3.flow3:core:compile is responsible for compilation
  * and calls this method to do so.
  *
  * In order to distinguish between an emerged / changed possible target class and
  * a class which has been matched previously but just didn't have to be proxied,
  * the latter are kept track of by an "unproxiedClass-*" cache entry.
  *
  * @return void
  */
 public function build()
 {
     $allAvailableClassNamesByPackage = $this->objectManager->getRegisteredClassNames();
     $possibleTargetClassNames = $this->getProxyableClasses($allAvailableClassNamesByPackage);
     $actualAspectClassNames = $this->reflectionService->getClassNamesByAnnotation('TYPO3\\FLOW3\\Annotations\\Aspect');
     sort($possibleTargetClassNames);
     sort($actualAspectClassNames);
     $this->aspectContainers = $this->buildAspectContainers($actualAspectClassNames);
     $rebuildEverything = FALSE;
     if ($this->objectConfigurationCache->has('allAspectClassesUpToDate') === FALSE) {
         $rebuildEverything = TRUE;
         $this->systemLogger->log('Aspects have been modified, therefore rebuilding all target classes.', LOG_INFO);
         $this->objectConfigurationCache->set('allAspectClassesUpToDate', TRUE);
     }
     $possibleTargetClassNameIndex = new ClassNameIndex();
     $possibleTargetClassNameIndex->setClassNames($possibleTargetClassNames);
     $targetClassNameCandidates = new ClassNameIndex();
     foreach ($this->aspectContainers as $aspectContainer) {
         $targetClassNameCandidates->applyUnion($aspectContainer->reduceTargetClassNames($possibleTargetClassNameIndex));
     }
     $targetClassNameCandidates->sort();
     foreach ($targetClassNameCandidates->getClassNames() as $targetClassName) {
         $isUnproxied = $this->objectConfigurationCache->has('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
         $hasCacheEntry = $this->compiler->hasCacheEntryForClass($targetClassName) || $isUnproxied;
         if ($rebuildEverything === TRUE || $hasCacheEntry === FALSE) {
             $proxyBuildResult = $this->buildProxyClass($targetClassName, $this->aspectContainers);
             if ($proxyBuildResult !== FALSE) {
                 if ($isUnproxied) {
                     $this->objectConfigurationCache->remove('unproxiedClass-' . str_replace('\\', '_', $targetClassName));
                 }
                 $this->systemLogger->log(sprintf('Built AOP proxy for class "%s".', $targetClassName), LOG_DEBUG);
             } else {
                 $this->objectConfigurationCache->set('unproxiedClass-' . str_replace('\\', '_', $targetClassName), TRUE);
             }
         }
     }
 }
Esempio n. 10
0
 /**
  * Shutdowns the object, saving parsed format strings to the cache.
  *
  * @return void
  */
 public function shutdownObject()
 {
     $this->cache->set('parsedFormats', $this->parsedFormats);
     $this->cache->set('parsedFormatsIndices', $this->parsedFormatsIndices);
     $this->cache->set('localizedSymbols', $this->localizedSymbols);
 }
Esempio n. 11
0
 /**
  * Caches the file modification times
  *
  * @return void
  */
 public function shutdownObject()
 {
     if ($this->modificationTimesChanged === TRUE) {
         $this->cache->set($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes', $this->filesAndModificationTimes);
     }
 }
Esempio n. 12
0
 /**
  * @test
  */
 public function flushCachesResetsBothRoutingCaches()
 {
     $this->mockFindMatchResultsCache->expects($this->once())->method('flush');
     $this->mockResolveCache->expects($this->once())->method('flush');
     $this->routerCachingAspect->flushCaches();
 }