/**
  * Around advice
  *
  * @around method(F3\FLOW3\MVC\Web\Routing\Router->findMatchResults())
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return array Result of the target method
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function cacheMatchingCall(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $requestPath = $joinPoint->getMethodArgument('requestPath');
     $cacheIdentifier = md5($requestPath);
     if ($this->findMatchResultsCache->has($cacheIdentifier)) {
         return $this->findMatchResultsCache->get($cacheIdentifier);
     }
     $matchResults = $joinPoint->getAdviceChain()->proceed($joinPoint);
     if ($matchResults !== NULL) {
         $this->findMatchResultsCache->set($cacheIdentifier, $matchResults);
     }
     return $matchResults;
 }
 /**
  * Around advice. Caches calls of parseTemplate() in classes implementing F3\Fluid\View\TemplateViewInterface.
  * This advice is only active if Fluid.syntaxTreeCache.enable is TRUE.
  *
  * @around within(F3\Fluid\View\TemplateViewInterface) && method(.*->parseTemplate()) && setting(Fluid.syntaxTreeCache.enable)
  * @param F3\FLOW3\AOP\JoinPointInterface $joinPoint The current join point
  * @return \F3\Fluid\Core\Parser\ParsedTemplateInterface template tree
  * @author Sebastian Kurfürst <*****@*****.**>
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function cacheParseTemplateCall(\F3\FLOW3\AOP\JoinPointInterface $joinPoint)
 {
     $templatePathAndFilename = $joinPoint->getMethodArgument('templatePathAndFilename');
     if (array_key_exists($templatePathAndFilename, $this->localSyntaxTreeCache)) {
         return $this->localSyntaxTreeCache[$templatePathAndFilename];
     }
     $cacheIdentifier = md5($templatePathAndFilename);
     if ($this->syntaxTreeCache->has($cacheIdentifier)) {
         return $this->syntaxTreeCache->get($cacheIdentifier);
     }
     $parsedTemplate = $joinPoint->getAdviceChain()->proceed($joinPoint);
     $this->syntaxTreeCache->set($cacheIdentifier, $parsedTemplate);
     $this->localSyntaxTreeCache[$templatePathAndFilename] = $parsedTemplate;
     return $parsedTemplate;
 }
 /**
  * Stores the given keypair under the returned UUID.
  *
  * @param \F3\FLOW3\Security\Cryptography\OpenSslRsaKey $publicKey The public key
  * @param \F3\FLOW3\Security\Cryptography\OpenSslRsaKey $privateKey The private key
  * @param boolean $usedForPasswords TRUE if this keypair should be used to decrypt passwords. (Decryption won't be allowed!)
  * @return UUID The UUID used for storing
  * @author Andreas Förthner <*****@*****.**>
  */
 private function storeKeyPair($publicKey, $privateKey, $usedForPasswords)
 {
     $keyPairUUID = str_replace('-', '_', \F3\FLOW3\Utility\Algorithms::generateUUID());
     $keyPair = array();
     $keyPair['publicKey'] = $publicKey;
     $keyPair['privateKey'] = $privateKey;
     $keyPair['usedForPasswords'] = $usedForPasswords;
     $this->keystoreCache->set($keyPairUUID, $keyPair);
     return $keyPairUUID;
 }
 /**
  * Exports the internal reflection data into the ReflectionData cache
  *
  * @return void
  * @throws \F3\FLOW3\Reflection\Exception if no cache has been injected
  * @author Robert Lemke <*****@*****.**>
  */
 protected function saveToCache()
 {
     if (!is_object($this->dataCache)) {
         throw new \F3\FLOW3\Reflection\Exception('A cache must be injected before initializing the Reflection Service.', 1232044697);
     }
     $nonCachedClassNames = array_diff_assoc($this->reflectedClassNames, $this->cachedClassNames);
     $this->log('Found ' . count($nonCachedClassNames) . ' classes whose reflection data was not cached previously.', LOG_DEBUG);
     foreach (array_keys($nonCachedClassNames) as $className) {
         $this->statusCache->set(str_replace('\\', '_', $className), '', array($this->statusCache->getClassTag($className)));
     }
     $data = array();
     $propertyNames = array('reflectedClassNames', 'abstractClasses', 'classConstructorMethodNames', 'classPropertyNames', 'classSchemata', 'classTagsValues', 'subClasses', 'finalClasses', 'finalMethods', 'staticMethods', 'interfaceImplementations', 'methodTagsValues', 'methodParameters', 'methodVisibilities', 'propertyTagsValues', 'taggedClasses');
     foreach ($propertyNames as $propertyName) {
         $data[$propertyName] = $this->{$propertyName};
     }
     $this->dataCache->set('ReflectionData', $data);
     $this->cachedClassNames = $this->reflectedClassNames;
 }
 /**
  * Initializes the AOP framework.
  *
  * During initialization the specified configuration of objects is 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.
  *
  * The class names of all proxied classes is stored back in the $objectConfigurations array.
  *
  * @param array &$objectConfigurations
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initialize(array &$objectConfigurations)
 {
     if ($this->isInitialized) {
         throw new \F3\FLOW3\AOP\Exception('The AOP framework has already been initialized!', 1169550994);
     }
     $this->isInitialized = TRUE;
     if ($this->proxyBuildInformationCache->has('targetAndProxyClassNames')) {
         $this->targetAndProxyClassNames = $this->proxyBuildInformationCache->get('targetAndProxyClassNames');
     }
     if (!$this->proxyBuildInformationCache->has('allProxyClassesUpToDate')) {
         $allAvailableClassNames = $this->getAllImplementationClassesFromObjectConfigurations($objectConfigurations);
         $cachedTargetClassNames = $this->proxyBuildInformationCache->has('targetClassNames') ? $this->proxyBuildInformationCache->get('targetClassNames') : array();
         $cachedAspectClassNames = $this->proxyBuildInformationCache->has('aspectClassNames') ? $this->proxyBuildInformationCache->get('aspectClassNames') : array();
         $actualTargetClassNames = $this->getProxyableClasses($allAvailableClassNames);
         $actualAspectClassNames = $this->reflectionService->getClassNamesByTag('aspect');
         sort($actualTargetClassNames);
         sort($actualAspectClassNames);
         $this->aspectContainers = $this->buildAspectContainers($allAvailableClassNames);
         $dirtyTargetClassNames = $actualTargetClassNames;
         if ($cachedAspectClassNames === $actualAspectClassNames) {
             $validProxyClassesCount = 0;
             $outdatedProxyClassesCount = 0;
             foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
                 if ($this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
                     $validProxyClassesCount++;
                     $dirtyTargetClassNames = array_diff($dirtyTargetClassNames, array($targetClassName));
                 } else {
                     $outdatedProxyClassesCount++;
                     unset($this->targetAndProxyClassNames[$targetClassName]);
                 }
             }
             $this->systemLogger->log(sprintf('At least one target class changed, aspects unchanged. Found %s valid and %s outdated proxy classes.', $validProxyClassesCount, $outdatedProxyClassesCount), LOG_INFO);
         } else {
             $this->systemLogger->log(sprintf('At least one aspect changed, rebuilding proxy classes for %s target classes.', count($actualTargetClassNames)), LOG_INFO);
             $this->proxyClassesCache->flush();
             $this->targetAndProxyClassNames = array();
         }
         foreach ($dirtyTargetClassNames as $targetClassName) {
             $proxyBuildResult = $this->proxyClassBuilder->buildProxyClass($targetClassName, $this->aspectContainers, $this->objectManager->getContext());
             if ($proxyBuildResult !== FALSE) {
                 $this->targetAndProxyClassNames[$targetClassName] = $proxyBuildResult['proxyClassName'];
                 $this->systemLogger->log(sprintf('Built proxy class "%s" for target class "%s" (length: %s).', $proxyBuildResult['proxyClassName'], $targetClassName, strlen($proxyBuildResult['proxyClassCode'])), LOG_DEBUG);
                 $this->proxyClassesCache->set(str_replace('\\', '_', $proxyBuildResult['proxyClassName']), $proxyBuildResult['proxyClassCode'], array($this->proxyClassesCache->getClassTag($targetClassName)));
             } else {
                 unset($this->targetAndProxyClassNames[$targetClassName]);
             }
         }
         $aspectClassesTags = array();
         foreach ($actualAspectClassNames as $aspectClassName) {
             $aspectClassesTags[] = $this->proxyBuildInformationCache->getClassTag($aspectClassName);
         }
         $this->proxyBuildInformationCache->set('targetAndProxyClassNames', $this->targetAndProxyClassNames);
         $this->proxyBuildInformationCache->set('aspectClassNames', $actualAspectClassNames, $aspectClassesTags);
         $this->proxyBuildInformationCache->set('targetClassNames', $actualTargetClassNames);
         $this->proxyBuildInformationCache->set('allProxyClassesUpToDate', '', array($this->proxyClassesCache->getClassTag()));
     }
     foreach ($this->targetAndProxyClassNames as $targetClassName => $proxyClassName) {
         if (class_exists($proxyClassName, FALSE)) {
             throw new \F3\FLOW3\AOP\Exception('Class ' . $proxyClassName . ' already exists.', 1229361833);
         }
         if (!$this->proxyClassesCache->has(str_replace('\\', '_', $proxyClassName))) {
             throw new \F3\FLOW3\AOP\Exception('No proxy class code for class "' . $proxyClassName . '" found in cache.', 1229362833);
         }
         $this->proxyClassesCache->requireOnce(str_replace('\\', '_', $proxyClassName));
         foreach ($objectConfigurations as $objectName => $objectConfiguration) {
             if ($objectConfiguration->getClassName() === $targetClassName) {
                 $objectConfigurations[$objectName]->setClassName($proxyClassName);
             }
         }
     }
 }
 /**
  * Caches the directories and their files
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function shutdownObject()
 {
     if ($this->directoriesChanged === TRUE) {
         $this->cache->set('directoriesAndFiles', $this->directoriesAndFiles);
     }
 }
 /**
  * Caches the file modification times
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function shutdownObject()
 {
     if ($this->modificationTimesChanged === TRUE) {
         $this->cache->set('filesAndModificationTimes', $this->filesAndModificationTimes);
     }
 }