Inheritance: extends AbstractFrontend
 /**
  * Redirects to the Neos backend on the given site, passing a one-time login token
  *
  * @param Site $site
  * @return void
  */
 public function switchSiteAction($site)
 {
     $token = Algorithms::generateRandomToken(32);
     $this->loginTokenCache->set($token, $this->currentSession->getId());
     $siteUri = $this->linkingService->createSiteUri($this->controllerContext, $site);
     $loginUri = $this->controllerContext->getUriBuilder()->reset()->uriFor('tokenLogin', ['token' => $token], 'Login', 'Neos.Neos');
     $this->redirectToUri($siteUri . $loginUri);
 }
 /**
  * @return string The current cache version identifier
  */
 public function render()
 {
     $version = $this->configurationCache->get('ConfigurationVersion');
     if ($version === false) {
         $version = time();
         $this->configurationCache->set('ConfigurationVersion', (string) $version);
     }
     return $version;
 }
 /**
  * Set up test dependencies
  *
  * @return void
  */
 public function setUp()
 {
     $this->cache = new StringFrontend('TestCache', new TransientMemoryBackend(new EnvironmentConfiguration('Hash Testing', '/some/path', PHP_MAXPATHLEN)));
     $this->cache->initializeObject();
     $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
     $this->hashService = new HashService();
     $this->inject($this->hashService, 'cache', $this->cache);
     $this->inject($this->hashService, 'objectManager', $this->mockObjectManager);
     $this->hashService->injectSettings($this->mockSettings);
 }
 /**
  * @test
  */
 public function storeResolvedUriPathConvertsObjectsImplementingCacheAwareInterfaceToCacheEntryIdentifier()
 {
     $mockObject = $this->createMock(CacheAwareInterface::class);
     $mockObject->expects($this->atLeastOnce())->method('getCacheEntryIdentifier')->will($this->returnValue('objectIdentifier'));
     $routeValues = ['b' => 'route values', 'someObject' => $mockObject];
     $cacheIdentifier = '264b593d59582adea4ccc52b33cc093f';
     $matchingUriPath = 'uncached/matching/uri';
     $this->mockResolveCache->expects($this->once())->method('set')->with($cacheIdentifier, $matchingUriPath);
     $this->routerCachingService->storeResolvedUriPath($matchingUriPath, $routeValues);
 }
 /**
  * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new
  * encryption key will be generated and stored in the cache.
  *
  * @return string The configured encryption key stored in Data/Persistent/EncryptionKey
  */
 protected function getEncryptionKey()
 {
     if ($this->encryptionKey === null) {
         $this->encryptionKey = $this->cache->get('encryptionKey');
     }
     if ($this->encryptionKey === false && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) {
         $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey');
     }
     if ($this->encryptionKey === false) {
         $this->encryptionKey = bin2hex(Utility\Algorithms::generateRandomBytes(48));
         $this->cache->set('encryptionKey', $this->encryptionKey);
     }
     return $this->encryptionKey;
 }
 /**
  * Loads all node types into memory.
  *
  * @return void
  */
 protected function loadNodeTypes()
 {
     $this->fullNodeTypeConfigurations = $this->fullConfigurationCache->get('fullNodeTypeConfigurations');
     $fillFullConfigurationCache = !is_array($this->fullNodeTypeConfigurations);
     $completeNodeTypeConfiguration = $this->configurationManager->getConfiguration('NodeTypes');
     foreach (array_keys($completeNodeTypeConfiguration) as $nodeTypeName) {
         if (!is_array($completeNodeTypeConfiguration[$nodeTypeName])) {
             continue;
         }
         $nodeType = $this->loadNodeType($nodeTypeName, $completeNodeTypeConfiguration, isset($this->fullNodeTypeConfigurations[$nodeTypeName]) ? $this->fullNodeTypeConfigurations[$nodeTypeName] : null);
         if ($fillFullConfigurationCache) {
             $this->fullNodeTypeConfigurations[$nodeTypeName] = $nodeType->getFullConfiguration();
         }
     }
     if ($fillFullConfigurationCache) {
         $this->fullConfigurationCache->set('fullNodeTypeConfigurations', $this->fullNodeTypeConfigurations);
     }
     $this->fullNodeTypeConfigurations = null;
 }
 /**
  * Logs a user in if a session identifier is available under the given token in the token cache.
  *
  * @param string $token
  * @return void
  */
 public function tokenLoginAction($token)
 {
     $newSessionId = $this->loginTokenCache->get($token);
     $this->loginTokenCache->remove($token);
     if ($newSessionId === false) {
         $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING);
         $this->redirect('index');
     }
     $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG);
     $newSession = $this->sessionManager->getSession($newSessionId);
     if ($newSession->canBeResumed()) {
         $newSession->resume();
     }
     if ($newSession->isStarted()) {
         $newSession->putData('lastVisitedNode', null);
     } else {
         $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR);
     }
     $this->replaceSessionCookie($newSessionId);
     $this->redirect('index', 'Backend\\Backend');
 }
 /**
  * Constructs the cache
  *
  * @param string $identifier A identifier which describes this cache
  * @param PhpCapableBackendInterface $backend Backend to be used for this cache
  */
 public function __construct($identifier, PhpCapableBackendInterface $backend)
 {
     parent::__construct($identifier, $backend);
 }
 /**
  * Store the changed directories and files back to the cache.
  *
  * @return void
  */
 protected function saveDetectedDirectoriesAndFiles()
 {
     $this->cache->set($this->identifier . '_directoriesAndFiles', json_encode($this->directoriesAndFiles));
 }
 /**
  * Flush all content cache entries
  *
  * @return void
  */
 public function flush()
 {
     $this->cache->flush();
 }
 /**
  * Caches the file modification times
  *
  * @return void
  */
 public function shutdownObject()
 {
     if ($this->modificationTimesChanged === true) {
         $this->cache->set($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes', json_encode($this->filesAndModificationTimes));
     }
 }
 /**
  * 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);
 }
Ejemplo n.º 13
0
 /**
  * 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);
 }
 /**
  * @test
  */
 public function getByTagCallsBackendAndReturnsIdentifiersAndValuesOfEntries()
 {
     $tag = 'sometag';
     $identifiers = ['one', 'two'];
     $entries = ['one' => 'one value', 'two' => 'two value'];
     $backend = $this->prepareDefaultBackend();
     $backend->expects($this->once())->method('findIdentifiersByTag')->with($this->equalTo($tag))->will($this->returnValue($identifiers));
     $backend->expects($this->exactly(2))->method('get')->will($this->onConsecutiveCalls('one value', 'two value'));
     $cache = new StringFrontend('StringFrontend', $backend);
     $this->assertEquals($entries, $cache->getByTag($tag), 'Did not receive the expected entries');
 }