/**
  * This method walks through the view configuration and applies
  * matching configurations in the order of their specifity score.
  * Possible options are currently the viewObjectName to specify
  * a different class that will be used to create the view and
  * an array of options that will be set on the view object.
  *
  * @param \TYPO3\Flow\Mvc\ActionRequest $request
  * @return array
  */
 public function getViewConfiguration(ActionRequest $request)
 {
     $cacheIdentifier = $this->createCacheIdentifier($request);
     $viewConfiguration = $this->cache->get($cacheIdentifier);
     if ($viewConfiguration === false) {
         $configurations = $this->configurationManager->getConfiguration('Views');
         $requestMatcher = new RequestMatcher($request);
         $context = new Context($requestMatcher);
         $matchingConfigurations = array();
         foreach ($configurations as $order => $configuration) {
             $requestMatcher->resetWeight();
             if (!isset($configuration['requestFilter'])) {
                 $matchingConfigurations[$order]['configuration'] = $configuration;
                 $matchingConfigurations[$order]['weight'] = $order;
             } else {
                 $result = $this->eelEvaluator->evaluate($configuration['requestFilter'], $context);
                 if ($result === false) {
                     continue;
                 }
                 $matchingConfigurations[$order]['configuration'] = $configuration;
                 $matchingConfigurations[$order]['weight'] = $requestMatcher->getWeight() + $order;
             }
         }
         usort($matchingConfigurations, function ($configuration1, $configuration2) {
             return $configuration1['weight'] > $configuration2['weight'];
         });
         $viewConfiguration = array();
         foreach ($matchingConfigurations as $key => $matchingConfiguration) {
             $viewConfiguration = Arrays::arrayMergeRecursiveOverrule($viewConfiguration, $matchingConfiguration['configuration']);
         }
         $this->cache->set($cacheIdentifier, $viewConfiguration);
     }
     return $viewConfiguration;
 }
 /**
  * @param Locale $locale
  * @param Language $language
  * @return string
  */
 public function getLanguageLocalizedName(Locale $locale, Language $language)
 {
     $cacheIdentifier = 'language-labels-' . $locale->getLanguage();
     $labelsFromCache = $this->languageCache->get($cacheIdentifier);
     if ($labelsFromCache) {
         return $labelsFromCache[$language->getKey()];
     }
     try {
         $raw = $this->cldrRepository->getModelForLocale($locale)->getRawArray('localeDisplayNames/languages');
     } catch (\Exception $e) {
         return 'Problem reading data for ' . $language->getKey();
     }
     $languages = $this->getLanguages();
     $labels = array();
     /** @var Language $currentLanguage */
     foreach ($languages as $currentLanguage) {
         try {
             $key = 'language[@type="' . $currentLanguage->getKey() . '"]';
             if (is_array($raw)) {
                 if (array_key_exists($key, $raw)) {
                     $labels[$currentLanguage->getKey()] = $raw[$key];
                 } else {
                     $labels[$currentLanguage->getKey()] = $currentLanguage->getName();
                 }
             } else {
                 $labels[$currentLanguage->getKey()] = 'Nothing found for ' . $currentLanguage->getKey();
             }
         } catch (\Exception $e) {
             // not found
             // $labels[$key] = 'Nothing found for ' . $language->getKey();
         }
     }
     $this->languageCache->set($cacheIdentifier, $labels);
     return $labels[$language->getKey()];
 }
 /**
  * Return the json array for a given locale, sourceCatalog, xliffPath and package.
  * The json will be cached.
  *
  * @param Locale $locale The locale
  * @throws \TYPO3\Flow\I18n\Exception
  * @return \TYPO3\Flow\Error\Result
  */
 public function getCachedJson(Locale $locale)
 {
     $cacheIdentifier = md5($locale);
     if ($this->xliffToJsonTranslationsCache->has($cacheIdentifier)) {
         $json = $this->xliffToJsonTranslationsCache->get($cacheIdentifier);
     } else {
         $labels = [];
         $localeChain = $this->localizationService->getLocaleChain($locale);
         foreach ($this->packagesRegisteredForAutoInclusion as $packageKey => $sourcesToBeIncluded) {
             if (!is_array($sourcesToBeIncluded)) {
                 continue;
             }
             $translationBasePath = Files::concatenatePaths([$this->packageManager->getPackage($packageKey)->getResourcesPath(), $this->xliffBasePath]);
             // We merge labels in the chain from the worst choice to best choice
             foreach (array_reverse($localeChain) as $allowedLocale) {
                 $localeSourcePath = Files::getNormalizedPath(Files::concatenatePaths([$translationBasePath, $allowedLocale]));
                 foreach ($sourcesToBeIncluded as $sourceName) {
                     foreach (glob($localeSourcePath . $sourceName . '.xlf') as $xliffPathAndFilename) {
                         $xliffPathInfo = pathinfo($xliffPathAndFilename);
                         $sourceName = str_replace($localeSourcePath, '', $xliffPathInfo['dirname'] . '/' . $xliffPathInfo['filename']);
                         $labels = Arrays::arrayMergeRecursiveOverrule($labels, $this->parseXliffToArray($xliffPathAndFilename, $packageKey, $sourceName));
                     }
                 }
             }
         }
         $json = json_encode($labels);
         $this->xliffToJsonTranslationsCache->set($cacheIdentifier, $json);
     }
     return $json;
 }
 /**
  * Lifecycle method, called after all dependencies have been injected.
  * Here, the typeConverter array gets initialized.
  *
  * @return void
  * @throws Exception\DuplicateTypeConverterException
  */
 public function initializeObject()
 {
     if ($this->cache->has('typeConverterMap')) {
         $this->typeConverters = $this->cache->get('typeConverterMap');
         return;
     }
     $this->typeConverters = $this->prepareTypeConverterMap();
     $this->cache->set('typeConverterMap', $this->typeConverters);
 }
Beispiel #5
0
 /**
  * Initializes the locale service
  *
  * @return void
  */
 public function initializeObject()
 {
     $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);
     }
 }
 /**
  * @Flow\Around("setting(TYPO3.Neos.typoScript.enableObjectTreeCache) && method(TYPO3\Neos\Domain\Service\TypoScriptService->getMergedTypoScriptObjectTree())")
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point
  * @return mixed
  */
 public function cacheGetMergedTypoScriptObjectTree(JoinPointInterface $joinPoint)
 {
     $currentSiteNode = $joinPoint->getMethodArgument('startNode');
     $cacheIdentifier = str_replace('.', '_', $currentSiteNode->getContext()->getCurrentSite()->getSiteResourcesPackageKey());
     if ($this->typoScriptCache->has($cacheIdentifier)) {
         $typoScriptObjectTree = $this->typoScriptCache->get($cacheIdentifier);
     } else {
         $typoScriptObjectTree = $joinPoint->getAdviceChain()->proceed($joinPoint);
         $this->typoScriptCache->set($cacheIdentifier, $typoScriptObjectTree);
     }
     return $typoScriptObjectTree;
 }
 /**
  * @param string $postalCode The zip code
  * @param string $countryCode The two character ISO 3166-1 country code
  * @return array|NULL The coordinates or NULL if none could be fetched
  */
 public function fetchCoordinatesByPostalCode($postalCode, $countryCode)
 {
     $cacheIdentifier = $postalCode . '-' . $countryCode;
     if (!isset($this->postalCodeCoordinates[$cacheIdentifier])) {
         try {
             $this->postalCodeCoordinates[$cacheIdentifier] = $this->geoCodingAdapter->fetchCoordinatesByPostalCode($postalCode, $countryCode);
             $this->cache->set('postalCodeCoordinates', $this->postalCodeCoordinates);
         } catch (NoSuchCoordinatesException $exception) {
             return null;
         }
     }
     return $this->postalCodeCoordinates[$cacheIdentifier];
 }
 /**
  * @param string $value
  * @throws Exception
  * @throws \TYPO3\Flow\Resource\Exception
  * @throws \TYPO3\Flow\Utility\Exception
  */
 protected function initializeValue($value)
 {
     if (!is_array($value)) {
         throw new Exception('Value must be an array, with source URI (sourceUri) and filename (filename)', 1425981082);
     }
     if (!isset($value['sourceUri'])) {
         throw new Exception('Missing source URI', 1425981083);
     }
     $sourceUri = trim($value['sourceUri']);
     if (!isset($value['filename'])) {
         throw new Exception('Missing filename URI', 1425981084);
     }
     $filename = trim($value['filename']);
     $overrideFilename = isset($value['overrideFilename']) ? trim($value['overrideFilename']) : $filename;
     if (!isset($this->options['downloadDirectory'])) {
         throw new Exception('Missing download directory data type option', 1425981085);
     }
     Files::createDirectoryRecursively($this->options['downloadDirectory']);
     $temporaryFileAndPathname = trim($this->options['downloadDirectory'] . $filename);
     $this->download($sourceUri, $temporaryFileAndPathname);
     $sha1Hash = sha1_file($temporaryFileAndPathname);
     # Try to add file extenstion if missing
     if (!$this->downloadCache->has($sha1Hash)) {
         $fileExtension = pathinfo($temporaryFileAndPathname, PATHINFO_EXTENSION);
         if (trim($fileExtension) === '') {
             $mimeTypeGuesser = new MimeTypeGuesser();
             $mimeType = $mimeTypeGuesser->guess($temporaryFileAndPathname);
             $this->logger->log(sprintf('Try to guess mime type for "%s" (%s), result: %s', $sourceUri, $filename, $mimeType), LOG_DEBUG);
             $fileExtension = MediaTypes::getFilenameExtensionFromMediaType($mimeType);
             if ($fileExtension !== '') {
                 $oldTemporaryDestination = $temporaryFileAndPathname;
                 $temporaryDestination = $temporaryFileAndPathname . '.' . $fileExtension;
                 copy($oldTemporaryDestination, $temporaryDestination);
                 $this->logger->log(sprintf('Rename "%s" to "%s"', $oldTemporaryDestination, $temporaryDestination), LOG_DEBUG);
             }
         }
     }
     $resource = $this->resourceManager->getResourceBySha1($sha1Hash);
     if ($resource === NULL) {
         $resource = $this->resourceManager->importResource($temporaryFileAndPathname);
         if ($filename !== $overrideFilename) {
             $resource->setFilename($overrideFilename);
         }
     }
     $this->temporaryFileAndPathname = $temporaryFileAndPathname;
     $this->downloadCache->set($sha1Hash, ['sha1Hash' => $sha1Hash, 'filename' => $filename, 'sourceUri' => $sourceUri, 'temporaryFileAndPathname' => $temporaryFileAndPathname]);
     $this->value = $resource;
 }
 /**
  * Save the found matches to the cache.
  *
  * @return void
  */
 public function savePolicyCache()
 {
     $tags = array('TYPO3_Flow_Aop');
     if (!$this->methodPermissionCache->has('methodPermission')) {
         $this->methodPermissionCache->set('methodPermission', $this->methodPermissions, $tags);
     }
 }
 /**
  * @Flow\Around("setting(Ttree.Embedly.logApiRequest) && within(Ttree\Embedly\Embedly) && method(public .*->(oembed|preview|objectify|extract|services)())")
  * @param JoinPointInterface $joinPoint The current join point
  * @return mixed
  */
 public function getResponseFromCache(JoinPointInterface $joinPoint)
 {
     $proxy = $joinPoint->getProxy();
     $key = ObjectAccess::getProperty($proxy, 'key');
     $params = $joinPoint->getMethodArgument('params');
     $cacheKey = md5($joinPoint->getClassName() . $joinPoint->getMethodName() . $key . json_encode($params));
     if ($this->responseCache->has($cacheKey)) {
         $this->systemLogger->log(sprintf('   cache hit Embedly::%s', $joinPoint->getMethodName()), LOG_DEBUG);
         return $this->responseCache->get($cacheKey);
     } else {
         $this->systemLogger->log(sprintf('   cache miss Embedly::%s', $joinPoint->getMethodName()), LOG_DEBUG);
     }
     $response = $joinPoint->getAdviceChain()->proceed($joinPoint);
     $this->responseCache->set($cacheKey, $response);
     return $response;
 }
 /**
  * Returns all sessions which are tagged by the specified tag.
  *
  * @param string $tag A valid Cache Frontend tag
  * @return array A collection of Session objects or an empty array if tag did not match
  * @api
  */
 public function getSessionsByTag($tag)
 {
     $taggedSessions = array();
     foreach ($this->metaDataCache->getByTag(Session::TAG_PREFIX . $tag) as $sessionIdentifier => $sessionInfo) {
         $session = new Session($sessionIdentifier, $sessionInfo['storageIdentifier'], $sessionInfo['lastActivityTimestamp'], $sessionInfo['tags']);
         $taggedSessions[] = $session;
     }
     return $taggedSessions;
 }
 /**
  * @return integer The current cache version identifier
  */
 public function getCacheVersion()
 {
     $version = $this->xliffToJsonTranslationsCache->get('ConfigurationVersion');
     if ($version === false) {
         $version = time();
         $this->xliffToJsonTranslationsCache->set('ConfigurationVersion', (string) $version);
     }
     return $version;
 }
 /**
  * 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);
     }
 }
 /**
  * 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);
     }
 }
 /**
  * Validate that all required assertion steps of a badge were completed and remove the stored assertion steps for all tokens
  *
  * @param BadgeClass $badgeClass
  * @param array $tokens
  * @return boolean
  */
 public function validateAndClearAssertionSteps(BadgeClass $badgeClass, array $tokens)
 {
     $completedAssertionSteps = array();
     foreach ($tokens as $token) {
         $assertionStep = $this->assertionStepStore->get($token);
         if ($assertionStep instanceof AssertionStep && $assertionStep->getBadgeClass() === $badgeClass) {
             $completedAssertionSteps[$assertionStep->getIdentifier()] = $assertionStep;
         }
     }
     foreach ($badgeClass->getAssertionSteps() as $stepIdentifier) {
         if (!isset($completedAssertionSteps[$stepIdentifier])) {
             return FALSE;
         }
     }
     foreach ($tokens as $token) {
         $this->assertionStepStore->remove($token);
     }
     return TRUE;
 }
 /**
  * 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);
     }
 }
Beispiel #17
0
 /**
  * @param Task $task
  * @param string $type
  */
 public function update(Task $task, $type)
 {
     switch ($type) {
         case TaskInterface::TYPE_DYNAMIC:
             $cacheKey = md5($task->getImplementation());
             $this->dynamicTaskLastExecutionCache->set($cacheKey, $task->getLastExecution());
             break;
         case TaskInterface::TYPE_PERSISTED:
             $this->taskRepository->update($task);
             break;
     }
 }
 /**
  * Set updated reflection data to caches.
  */
 protected function updateReflectionData()
 {
     $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($this->produceCacheIdentifierFromClassName($className), '');
     }
     $data = [];
     $propertyNames = ['classReflectionData', 'classSchemata', 'annotatedClasses', 'classesByMethodAnnotations'];
     foreach ($propertyNames as $propertyName) {
         $data[$propertyName] = $this->{$propertyName};
     }
     $this->reflectionDataCompiletimeCache->set('ReflectionData', $data);
 }
 /**
  * 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\Flow\Reflection\Exception if no cache has been injected
  */
 public function saveToCache()
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     if ($this->loadFromClassSchemaRuntimeCache === TRUE) {
         return;
     }
     if (!$this->reflectionDataCompiletimeCache instanceof FrontendInterface) {
         throw new 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);
             }
         }
     }
 }
 /**
  * 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 pointcut 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.flow: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(Flow\Aspect::class);
     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();
     $treatedSubClasses = new ClassNameIndex();
     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) {
                 // In case the proxy was not build because there was nothing adviced,
                 // it might be an advice in the parent and so we need to try to treat this class.
                 $treatedSubClasses = $this->addBuildMethodsAndAdvicesCodeToClass($targetClassName, $treatedSubClasses);
             }
             $treatedSubClasses = $this->proxySubClassesOfClassToEnsureAdvices($targetClassName, $targetClassNameCandidates, $treatedSubClasses);
             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);
             }
         }
     }
 }
 /**
  * @param NodeInterface $node
  * @return void
  */
 public function refreshCacheIfNecessary(NodeInterface $node)
 {
     if ($node->getNodeType()->isOfType('Nezaniel.SystemNodes:SystemNode')) {
         $currentPath = [];
         $recursiveIterator = function (array $items) use(&$recursiveIterator, &$currentPath, $node) {
             foreach ($items as $key => $entry) {
                 $currentPath[] = $key;
                 if (is_array($entry)) {
                     $recursiveIterator($entry);
                 } elseif ($entry === $node->getIdentifier()) {
                     $this->systemNodeIdentifiers = Arrays::unsetValueByPath($this->systemNodeIdentifiers, $currentPath);
                 }
                 array_pop($currentPath);
             }
         };
         $recursiveIterator($this->systemNodeIdentifiers);
         $this->initializeSystemNode($node);
         $this->cache->set('systemNodeIdentifiers', $this->systemNodeIdentifiers);
     }
 }
 /**
  * Shows the methods represented by the given security resource
  *
  * @param string $resourceName The name of the resource as stated in the policy
  * @return void
  */
 public function showMethodsForResourceCommand($resourceName)
 {
     if ($this->policyCache->has('acls')) {
         $classes = array();
         $acls = $this->policyCache->get('acls');
         foreach ($acls as $classAndMethodName => $aclEntry) {
             if (strpos($classAndMethodName, '->') === FALSE) {
                 continue;
             }
             list($className, $methodName) = explode('->', $classAndMethodName);
             $className = $this->objectManager->getCaseSensitiveObjectName($className);
             $reflectionClass = new \ReflectionClass($className);
             foreach ($reflectionClass->getMethods() as $casSensitiveMethodName) {
                 if ($methodName === strtolower($casSensitiveMethodName->getName())) {
                     $methodName = $casSensitiveMethodName->getName();
                     break;
                 }
             }
             foreach ($aclEntry as $resources) {
                 if (array_key_exists($resourceName, $resources)) {
                     $classes[$className][$methodName] = $methodName;
                     break;
                 }
             }
         }
         if (count($classes) === 0) {
             $this->outputLine('The given Resource did not match any method or is unknown.');
             $this->quit(1);
         }
         foreach ($classes as $className => $methods) {
             $this->outputLine(PHP_EOL . $className);
             foreach ($methods as $methodName) {
                 $this->outputLine('  ' . $methodName);
             }
         }
     } else {
         $this->outputLine('Could not find any policy entries, please warmup caches!');
     }
 }
 /**
  * Get the size of a Flow Resource object that contains an image file.
  *
  * @param FlowResource $resource
  * @return array width and height as keys
  * @throws ImageFileException
  */
 public function getImageSize(FlowResource $resource)
 {
     $cacheIdentifier = $resource->getCacheEntryIdentifier();
     $imageSize = $this->imageSizeCache->get($cacheIdentifier);
     if ($imageSize !== false) {
         return $imageSize;
     }
     // TODO: Special handling for SVG should be refactored at a later point.
     if ($resource->getMediaType() === 'image/svg+xml') {
         $imageSize = ['width' => null, 'height' => null];
     } else {
         try {
             $imagineImage = $this->imagineService->read($resource->getStream());
             $sizeBox = $imagineImage->getSize();
             $imageSize = array('width' => $sizeBox->getWidth(), 'height' => $sizeBox->getHeight());
         } catch (\Exception $e) {
             throw new ImageFileException(sprintf('The given resource was not an image file your choosen driver can open. The original error was: %s', $e->getMessage()), 1336662898);
         }
     }
     $this->imageSizeCache->set($cacheIdentifier, $imageSize);
     return $imageSize;
 }
 /**
  * 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;
 }
 /**
  * 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 pointcut 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.flow: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\\Flow\\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);
             }
         }
     }
 }
 /**
  * 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('localizedLiterals', $this->localizedLiterals);
 }
 /**
  * Removes the session info cache entry for the specified session.
  *
  * Note that this function does only remove the "head" cache entry, not the
  * related data referred to by the storage identifier.
  *
  * @param string $sessionIdentifier
  * @return void
  */
 protected function removeSessionMetaDataCacheEntry($sessionIdentifier)
 {
     $this->metaDataCache->remove($sessionIdentifier);
 }
 /**
  * @return boolean
  */
 protected function hasFrozenCacheInProduction()
 {
     return $this->environment->getContext()->isProduction() && $this->reflectionDataRuntimeCache->getBackend()->isFrozen();
 }
 /**
  * Flushes 'findMatchResults' and 'resolve' caches for the given $tag
  *
  * @param string $tag
  * @return void
  */
 public function flushCachesByTag($tag)
 {
     $this->routeCache->flushByTag($tag);
     $this->resolveCache->flushByTag($tag);
 }
 /**
  * Flushes 'findMatchResults' and 'resolve' caches for the given $tag
  *
  * @param string $tag
  * @return void
  */
 public function flushCachesByTag($tag)
 {
     $this->findMatchResultsCache->flushByTag($tag);
     $this->resolveCache->flushByTag($tag);
 }