get() public method

Important: If possible, instances of Prototype objects should always be created with the new keyword and Singleton objects should rather be injected by some type of Dependency Injection.
public get ( string $objectName ) : object
$objectName string The name of the object to return an instance of
return object The object instance
Example #1
0
 /**
  * Set the routes configuration for the Neos setup and configures the routing component
  * to skip initialisation, which would overwrite the specific settings again.
  *
  * @param ComponentContext $componentContext
  * @return void
  */
 public function handle(ComponentContext $componentContext)
 {
     $configurationSource = $this->objectManager->get(\Neos\Flow\Configuration\Source\YamlSource::class);
     $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('Neos.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     $this->router->setRoutesConfiguration($routesConfiguration);
     $componentContext->setParameter(\Neos\Flow\Mvc\Routing\RoutingComponent::class, 'skipRouterInitialization', true);
 }
 /**
  * @param array $chainConfiguration
  * @return ComponentChain
  * @throws Exception
  */
 public function create(array $chainConfiguration)
 {
     if (empty($chainConfiguration)) {
         return null;
     }
     $arraySorter = new PositionalArraySorter($chainConfiguration);
     $sortedChainConfiguration = $arraySorter->toArray();
     $chainComponents = [];
     foreach ($sortedChainConfiguration as $componentName => $configuration) {
         $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : [];
         if (isset($configuration['chain'])) {
             $component = $this->create($configuration['chain']);
         } else {
             if (!isset($configuration['component'])) {
                 throw new Exception(sprintf('Component chain could not be created because no component class name is configured for component "%s"', $componentName), 1401718283);
             }
             $component = $this->objectManager->get($configuration['component'], $componentOptions);
             if (!$component instanceof ComponentInterface) {
                 throw new Exception(sprintf('Component chain could not be created because the class "%s" does not implement the ComponentInterface, in component "%s" does not implement', $configuration['component'], $componentName), 1401718283);
             }
         }
         $chainComponents[] = $component;
     }
     return new ComponentChain(['components' => $chainComponents]);
 }
 /**
  * Adds all validators that extend the AssetValidatorInterface.
  *
  * @return void
  */
 protected function initializeObject()
 {
     $assetValidatorImplementationClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface(AssetValidatorInterface::class);
     foreach ($assetValidatorImplementationClassNames as $assetValidatorImplementationClassName) {
         $this->addValidator($this->objectManager->get($assetValidatorImplementationClassName));
     }
 }
 /**
  * This object is created very early and is part of the blacklisted "Neos\Flow\Aop" namespace so we can't rely on AOP for the property injection.
  *
  * @param ObjectManagerInterface $objectManager
  * @return void
  */
 public function injectObjectManager(ObjectManagerInterface $objectManager)
 {
     if ($this->objectManager === null) {
         $this->objectManager = $objectManager;
         /** @var CacheManager $cacheManager */
         $cacheManager = $this->objectManager->get(CacheManager::class);
         $this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
         $this->runtimeExpressions = $this->runtimeExpressionsCache->requireOnce('Flow_Aop_RuntimeExpressions');
     }
 }
 /**
  * Execute the job
  *
  * A job should finish itself after successful execution using the queue methods.
  *
  * @param QueueInterface $queue
  * @param Message $message
  * @return boolean TRUE If the execution was successful
  * @throws \Exception
  */
 public function execute(QueueInterface $queue, Message $message)
 {
     $service = $this->objectManager->get($this->className);
     $this->deferMethodCallAspect->setProcessingJob(true);
     try {
         $methodName = $this->methodName;
         call_user_func_array([$service, $methodName], $this->arguments);
         return true;
     } catch (\Exception $exception) {
         $this->deferMethodCallAspect->setProcessingJob(false);
         throw $exception;
     }
 }
 /**
  * Handle an Exception thrown while rendering TypoScript according to
  * settings specified in Neos.Fusion.rendering.exceptionHandler
  *
  * @param array $typoScriptPath
  * @param \Exception $exception
  * @param boolean $useInnerExceptionHandler
  * @return string
  * @throws InvalidConfigurationException
  */
 public function handleRenderingException($typoScriptPath, \Exception $exception, $useInnerExceptionHandler = false)
 {
     $typoScriptConfiguration = $this->getConfigurationForPath($typoScriptPath);
     if (isset($typoScriptConfiguration['__meta']['exceptionHandler'])) {
         $exceptionHandlerClass = $typoScriptConfiguration['__meta']['exceptionHandler'];
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for property "@exceptionHandler".';
     } else {
         if ($useInnerExceptionHandler === true) {
             $exceptionHandlerClass = $this->settings['rendering']['innerExceptionHandler'];
         } else {
             $exceptionHandlerClass = $this->settings['rendering']['exceptionHandler'];
         }
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for setting "Neos.Fusion.rendering.exceptionHandler".';
     }
     $exceptionHandler = null;
     if ($this->objectManager->isRegistered($exceptionHandlerClass)) {
         $exceptionHandler = $this->objectManager->get($exceptionHandlerClass);
     }
     if ($exceptionHandler === null || !$exceptionHandler instanceof AbstractRenderingExceptionHandler) {
         $message = sprintf($invalidExceptionHandlerMessage . "\n" . 'Please specify a fully qualified classname to a subclass of %2$s\\AbstractRenderingExceptionHandler.' . "\n" . 'You might implement an own handler or use one of the following:' . "\n" . '%2$s\\AbsorbingHandler' . "\n" . '%2$s\\HtmlMessageHandler' . "\n" . '%2$s\\PlainTextHandler' . "\n" . '%2$s\\ThrowingHandler' . "\n" . '%2$s\\XmlCommentHandler', $exceptionHandlerClass, 'Neos\\Fusion\\Core\\ExceptionHandlers');
         throw new InvalidConfigurationException($message, 1368788926);
     }
     $exceptionHandler->setRuntime($this);
     if (array_key_exists('__objectType', $typoScriptConfiguration)) {
         $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']);
     }
     $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception);
     return $output;
 }
 /**
  * Emits a signal when an Advice is invoked
  *
  * The advice is not proxyable, so the signal is dispatched manually here.
  *
  * @param object $aspectObject
  * @param string $methodName
  * @param JoinPointInterface $joinPoint
  * @return void
  * @Flow\Signal
  */
 protected function emitAdviceInvoked($aspectObject, $methodName, $joinPoint)
 {
     if ($this->dispatcher === null) {
         $this->dispatcher = $this->objectManager->get(Dispatcher::class);
     }
     $this->dispatcher->dispatch(self::class, 'adviceInvoked', [$aspectObject, $methodName, $joinPoint]);
 }
 /**
  * Returns the static value of the given operand, this might be also a global object
  *
  * @param mixed $expression The expression string representing the operand
  * @return mixed The calculated value
  */
 public function getValueForOperand($expression)
 {
     if (is_array($expression)) {
         $result = [];
         foreach ($expression as $expressionEntry) {
             $result[] = $this->getValueForOperand($expressionEntry);
         }
         return $result;
     } elseif (is_numeric($expression)) {
         return $expression;
     } elseif ($expression === true) {
         return true;
     } elseif ($expression === false) {
         return false;
     } elseif ($expression === null) {
         return null;
     } elseif (strpos($expression, 'context.') === 0) {
         $objectAccess = explode('.', $expression, 3);
         $globalObjectsRegisteredClassName = $this->globalObjects[$objectAccess[1]];
         $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName);
         $this->securityContext->withoutAuthorizationChecks(function () use($globalObject, $objectAccess, &$globalObjectValue) {
             $globalObjectValue = $this->getObjectValueByPath($globalObject, $objectAccess[2]);
         });
         return $globalObjectValue;
     } else {
         return trim($expression, '"\'');
     }
 }
 /**
  * Adds a setting filter to the pointcut filter composite
  *
  * @param string $operator The operator
  * @param string $configurationPath The path to the settings option, that should be used
  * @param PointcutFilterComposite $pointcutFilterComposite An instance of the pointcut filter composite. The result (ie. the custom filter) will be added to this composite object.
  * @return void
  */
 protected function parseDesignatorSetting($operator, $configurationPath, PointcutFilterComposite $pointcutFilterComposite)
 {
     $filter = new PointcutSettingFilter($configurationPath);
     /** @var ConfigurationManager $configurationManager */
     $configurationManager = $this->objectManager->get(ConfigurationManager::class);
     $filter->injectConfigurationManager($configurationManager);
     $pointcutFilterComposite->addFilter($operator, $filter);
 }
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) {
         $this->objectManager->get(LockManager::class)->unlockSite();
     }
     exit($this->response->getExitCode());
 }
 /**
  * Emits a signal when a Request has been dispatched
  *
  * The action request is not proxyable, so the signal is dispatched manually here.
  * The safeguard allows unit tests without the dispatcher dependency.
  *
  * @param ActionRequest $request
  * @return void
  * @Flow\Signal
  */
 protected function emitRequestDispatched($request)
 {
     if ($this->objectManager !== null) {
         $dispatcher = $this->objectManager->get(SignalSlotDispatcher::class);
         if ($dispatcher !== null) {
             $dispatcher->dispatch(ActionRequest::class, 'requestDispatched', [$request]);
         }
     }
 }
 /**
  * @param PropertyMappingConfiguration $propertyMappingConfiguration
  * @param string $dataType
  * @return boolean
  */
 protected function setTypeConverterForType(PropertyMappingConfiguration $propertyMappingConfiguration, $dataType)
 {
     if (!isset($this->typesConfiguration[$dataType]) || !isset($this->typesConfiguration[$dataType]['typeConverter'])) {
         return false;
     }
     $typeConverter = $this->objectManager->get($this->typesConfiguration[$dataType]['typeConverter']);
     $propertyMappingConfiguration->setTypeConverter($typeConverter);
     $this->setTypeConverterOptionsForType($propertyMappingConfiguration, $this->typesConfiguration[$dataType]['typeConverter'], $dataType);
     return true;
 }
Example #13
0
 /**
  * @When /^I import the last exported site$/
  */
 public function iImportTheLastExportedSite()
 {
     // Persist any pending entity insertions (caused by lazy creation of live Workspace)
     // This is a workaround which should be solved by properly isolating all read-only steps
     $this->getSubContext('flow')->persistAll();
     $this->resetNodeInstances();
     /** @var SiteImportService $siteImportService */
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile($this->lastExportedSiteXmlPathAndFilename);
 }
 /**
  * Builds the needed pointcut filters for matching the policy privileges
  *
  * @return boolean
  */
 protected function buildPointcutFilters()
 {
     $this->filters = [];
     /** @var PolicyService $policyService */
     $policyService = $this->objectManager->get(PolicyService::class);
     /** @var MethodPrivilegeInterface[] $methodPrivileges */
     $methodPrivileges = $policyService->getAllPrivilegesByType(MethodPrivilegeInterface::class);
     foreach ($methodPrivileges as $privilege) {
         $this->filters[$privilege->getCacheEntryIdentifier()] = $privilege->getPointcutFilterComposite();
     }
 }
 /**
  * Parses the request body according to the media type.
  *
  * @param HttpRequest $httpRequest
  * @return array
  */
 protected function parseRequestBody(HttpRequest $httpRequest)
 {
     $requestBody = $httpRequest->getContent();
     if ($requestBody === null || $requestBody === '') {
         return [];
     }
     $mediaTypeConverter = $this->objectManager->get(MediaTypeConverterInterface::class);
     $propertyMappingConfiguration = new PropertyMappingConfiguration();
     $propertyMappingConfiguration->setTypeConverter($mediaTypeConverter);
     $propertyMappingConfiguration->setTypeConverterOption(MediaTypeConverterInterface::class, MediaTypeConverterInterface::CONFIGURATION_MEDIA_TYPE, $httpRequest->getHeader('Content-Type'));
     $arguments = $this->propertyMapper->convert($requestBody, 'array', $propertyMappingConfiguration);
     return $arguments;
 }
 /**
  * Returns all class names implementing the ThumbnailGeneratorInterface.
  *
  * @Flow\CompileStatic
  * @param ObjectManagerInterface $objectManager
  * @return ThumbnailGeneratorInterface[]
  */
 public static function getThumbnailGeneratorClassNames($objectManager)
 {
     /** @var ReflectionService $reflectionService */
     $reflectionService = $objectManager->get(ReflectionService::class);
     $generatorClassNames = $reflectionService->getAllImplementationClassNamesForInterface(ThumbnailGeneratorInterface::class);
     $configurationManager = $objectManager->get(ConfigurationManager::class);
     $generatorOptions = $configurationManager->getConfiguration('Settings', 'Neos.Media.thumbnailGenerators');
     $generators = array();
     foreach ($generatorClassNames as $generatorClassName) {
         if (isset($generatorOptions[$generatorClassName]['disable']) && $generatorOptions[$generatorClassName]['disable'] === true) {
             continue;
         }
         if (isset($generatorOptions[$generatorClassName]['priority'])) {
             $priority = $generatorOptions[$generatorClassName]['priority'];
         } else {
             $priority = $generatorClassName::getPriority();
         }
         $generators[] = array('priority' => (int) $priority, 'className' => $generatorClassName);
     }
     $sorter = new PositionalArraySorter($generators, 'priority');
     return array_reverse($sorter->toArray());
 }
 /**
  * Around advice, wrapping every method of a scope session object. It redirects
  * all method calls to the session object once there is one.
  *
  * @param JoinPointInterface $joinPoint The current join point
  * @return mixed
  * @Flow\Around("filter(Neos\Flow\Session\Aspect\SessionObjectMethodsPointcutFilter)")
  */
 public function callMethodOnOriginalSessionObject(JoinPointInterface $joinPoint)
 {
     $objectName = $this->objectManager->getObjectNameByClassName(get_class($joinPoint->getProxy()));
     $methodName = $joinPoint->getMethodName();
     $proxy = $joinPoint->getProxy();
     if (!isset($this->sessionOriginalInstances[$objectName])) {
         $this->sessionOriginalInstances[$objectName] = $this->objectManager->get($objectName);
     }
     if ($this->sessionOriginalInstances[$objectName] === $proxy) {
         return $joinPoint->getAdviceChain()->proceed($joinPoint);
     } else {
         return call_user_func_array([$this->sessionOriginalInstances[$objectName], $methodName], $joinPoint->getMethodArguments());
     }
 }
 /**
  * Resolve an operation, taking runtime constraints into account.
  *
  * @param string      $operationName
  * @param array|mixed $context
  * @throws FlowQueryException
  * @return OperationInterface the resolved operation
  */
 public function resolveOperation($operationName, $context)
 {
     if (!isset($this->operations[$operationName])) {
         throw new FlowQueryException('Operation "' . $operationName . '" not found.', 1332491837);
     }
     foreach ($this->operations[$operationName] as $operationClassName) {
         /** @var OperationInterface $operation */
         $operation = $this->objectManager->get($operationClassName);
         if ($operation->canEvaluate($context)) {
             return $operation;
         }
     }
     throw new FlowQueryException('No operation which satisfies the runtime constraints found for "' . $operationName . '".', 1332491864);
 }
 /**
  * Calls a behat step method
  *
  * @Flow\Internal
  * @param string $testHelperObjectName
  * @param string $methodName
  * @param boolean $withoutSecurityChecks
  */
 public function callBehatStepCommand($testHelperObjectName, $methodName, $withoutSecurityChecks = false)
 {
     $testHelper = $this->objectManager->get($testHelperObjectName);
     $rawMethodArguments = $this->request->getExceedingArguments();
     $mappedArguments = [];
     for ($i = 0; $i < count($rawMethodArguments); $i += 2) {
         $mappedArguments[] = $this->propertyMapper->convert($rawMethodArguments[$i + 1], $rawMethodArguments[$i]);
     }
     $result = null;
     try {
         if ($withoutSecurityChecks === true) {
             $this->securityContext->withoutAuthorizationChecks(function () use($testHelper, $methodName, $mappedArguments, &$result) {
                 $result = call_user_func_array([$testHelper, $methodName], $mappedArguments);
             });
         } else {
             $result = call_user_func_array([$testHelper, $methodName], $mappedArguments);
         }
     } catch (\Exception $exception) {
         $this->outputLine('EXCEPTION: %s %d %s in %s:%s %s', [get_class($exception), $exception->getCode(), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $exception->getTraceAsString()]);
         return;
     }
     $this->output('SUCCESS: %s', [$result]);
 }
 /**
  * Get available data source implementations
  *
  * @param ObjectManagerInterface $objectManager
  * @return array Data source class names indexed by identifier
  * @Flow\CompileStatic
  * @throws NeosException
  */
 public static function getDataSources($objectManager)
 {
     $reflectionService = $objectManager->get(ReflectionService::class);
     $dataSources = array();
     $dataSourceClassNames = $reflectionService->getAllImplementationClassNamesForInterface(DataSourceInterface::class);
     /** @var $dataSourceClassName DataSourceInterface */
     foreach ($dataSourceClassNames as $dataSourceClassName) {
         $identifier = $dataSourceClassName::getIdentifier();
         if (isset($dataSources[$identifier])) {
             throw new NeosException(sprintf('Data source with identifier "%s" is already defined in class %s.', $identifier, $dataSourceClassName), 1414088185);
         }
         $dataSources[$identifier] = $dataSourceClassName;
     }
     return $dataSources;
 }
Example #21
0
 /**
  * Generate a TypoScript prototype definition for a given node type
  *
  * A prototype will be rendererd with the generator-class defined in the
  * nodeType-configuration 'fusion.prototypeGenerator'
  *
  * @param NodeType $nodeType
  * @return string
  * @throws \Neos\Neos\Domain\Exception
  */
 protected function generateTypoScriptForNodeType(NodeType $nodeType)
 {
     if ($nodeType->hasConfiguration('options.fusion.prototypeGenerator') && $nodeType->getConfiguration('options.fusion.prototypeGenerator') !== null) {
         $generatorClassName = $nodeType->getConfiguration('options.fusion.prototypeGenerator');
         if (!class_exists($generatorClassName)) {
             throw new \Neos\Neos\Domain\Exception('Fusion prototype-generator Class ' . $generatorClassName . ' does not exist');
         }
         $generator = $this->objectManager->get($generatorClassName);
         if (!$generator instanceof DefaultPrototypeGeneratorInterface) {
             throw new \Neos\Neos\Domain\Exception('Fusion prototype-generator Class ' . $generatorClassName . ' does not implement interface ' . DefaultPrototypeGeneratorInterface::class);
         }
         return $generator->generate($nodeType);
     }
     return '';
 }
 /**
  * Collects all TypeConverter implementations in a multi-dimensional array with source and target types.
  *
  * @return array
  * @throws Exception\DuplicateTypeConverterException
  * @see getTypeConverters
  */
 protected function prepareTypeConverterMap()
 {
     $typeConverterMap = [];
     $typeConverterClassNames = static::getTypeConverterImplementationClassNames($this->objectManager);
     foreach ($typeConverterClassNames as $typeConverterClassName) {
         $typeConverter = $this->objectManager->get($typeConverterClassName);
         foreach ($typeConverter->getSupportedSourceTypes() as $supportedSourceType) {
             if (isset($typeConverterMap[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()])) {
                 throw new Exception\DuplicateTypeConverterException('There exist at least two converters which handle the conversion from "' . $supportedSourceType . '" to "' . $typeConverter->getSupportedTargetType() . '" with priority "' . $typeConverter->getPriority() . '": ' . get_class($this->typeConverters[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()]) . ' and ' . get_class($typeConverter), 1297951378);
             }
             $typeConverterMap[$supportedSourceType][$typeConverter->getSupportedTargetType()][$typeConverter->getPriority()] = $typeConverterClassName;
         }
     }
     return $typeConverterMap;
 }
 /**
  * Add attribute descriptions to a given tag.
  * Initializes the view helper and its arguments, and then reads out the list of arguments.
  *
  * @param string $className Class name where to add the attribute descriptions
  * @param \SimpleXMLElement $xsdElement XML element to add the attributes to.
  * @return void
  */
 protected function addAttributes($className, \SimpleXMLElement $xsdElement)
 {
     $viewHelper = $this->objectManager->get($className);
     $argumentDefinitions = $viewHelper->prepareArguments();
     /** @var $argumentDefinition ArgumentDefinition */
     foreach ($argumentDefinitions as $argumentDefinition) {
         $xsdAttribute = $xsdElement->addChild('xsd:attribute');
         $xsdAttribute['type'] = 'xsd:string';
         $xsdAttribute['name'] = $argumentDefinition->getName();
         $this->addDocumentation($argumentDefinition->getDescription(), $xsdAttribute);
         if ($argumentDefinition->isRequired()) {
             $xsdAttribute['use'] = 'required';
         }
     }
 }
 /**
  * Sets the internal filters based on the given configuration.
  *
  * @param array $filterSettings The filter settings
  * @return void
  */
 protected function buildFiltersFromSettings(array $filterSettings)
 {
     foreach ($filterSettings as $singleFilterSettings) {
         $patternType = isset($singleFilterSettings['pattern']) ? $singleFilterSettings['pattern'] : $singleFilterSettings['patternType'];
         $patternClassName = $this->requestPatternResolver->resolveRequestPatternClass($patternType);
         $patternOptions = isset($singleFilterSettings['patternOptions']) ? $singleFilterSettings['patternOptions'] : [];
         /** @var $requestPattern RequestPatternInterface */
         $requestPattern = $this->objectManager->get($patternClassName, $patternOptions);
         // The following check needed for backwards compatibility:
         // Previously each pattern had only one option that was set via the setPattern() method. Now options are passed to the constructor.
         if (isset($singleFilterSettings['patternValue']) && is_callable([$requestPattern, 'setPattern'])) {
             $requestPattern->setPattern($singleFilterSettings['patternValue']);
         }
         $interceptor = $this->objectManager->get($this->interceptorResolver->resolveInterceptorClass($singleFilterSettings['interceptor']));
         $this->filters[] = $this->objectManager->get(RequestFilter::class, $requestPattern, $interceptor);
     }
 }
 /**
  * Get a password hashing strategy
  *
  * @param string $strategyIdentifier
  * @return array<PasswordHashingStrategyInterface> and string
  * @throws MissingConfigurationException
  */
 protected function getPasswordHashingStrategyAndIdentifier($strategyIdentifier = 'default')
 {
     if (isset($this->passwordHashingStrategies[$strategyIdentifier])) {
         return [$this->passwordHashingStrategies[$strategyIdentifier], $strategyIdentifier];
     }
     if ($strategyIdentifier === 'default') {
         if (!isset($this->strategySettings['default'])) {
             throw new MissingConfigurationException('No default hashing strategy configured', 1320758427);
         }
         $strategyIdentifier = $this->strategySettings['default'];
     }
     if (!isset($this->strategySettings[$strategyIdentifier])) {
         throw new MissingConfigurationException('No hashing strategy with identifier "' . $strategyIdentifier . '" configured', 1320758776);
     }
     $strategyObjectName = $this->strategySettings[$strategyIdentifier];
     $this->passwordHashingStrategies[$strategyIdentifier] = $this->objectManager->get($strategyObjectName);
     return [$this->passwordHashingStrategies[$strategyIdentifier], $strategyIdentifier];
 }
 /**
  * Replace resource on an asset. Takes variants and redirect handling into account.
  *
  * @param AssetInterface $asset
  * @param PersistentResource $resource
  * @param array $options
  * @return void
  */
 public function replaceAssetResource(AssetInterface $asset, PersistentResource $resource, array $options = [])
 {
     $originalAssetResource = $asset->getResource();
     $asset->setResource($resource);
     if (isset($options['keepOriginalFilename']) && (bool) $options['keepOriginalFilename'] === true) {
         $asset->getResource()->setFilename($originalAssetResource->getFilename());
     }
     $uriMapping = [];
     $redirectHandlerEnabled = isset($options['generateRedirects']) && (bool) $options['generateRedirects'] === true && $this->packageManager->isPackageAvailable('Neos.RedirectHandler');
     if ($redirectHandlerEnabled) {
         $uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalAssetResource)] = $this->resourceManager->getPublicPersistentResourceUri($asset->getResource());
     }
     if (method_exists($asset, 'getVariants')) {
         $variants = $asset->getVariants();
         /** @var AssetVariantInterface $variant */
         foreach ($variants as $variant) {
             $originalVariantResource = $variant->getResource();
             $variant->refresh();
             if (method_exists($variant, 'getAdjustments')) {
                 foreach ($variant->getAdjustments() as $adjustment) {
                     if (method_exists($adjustment, 'refit')) {
                         $adjustment->refit($asset);
                     }
                 }
             }
             if ($redirectHandlerEnabled) {
                 $uriMapping[$this->resourceManager->getPublicPersistentResourceUri($originalVariantResource)] = $this->resourceManager->getPublicPersistentResourceUri($variant->getResource());
             }
             $this->getRepository($variant)->update($variant);
         }
     }
     if ($redirectHandlerEnabled) {
         /** @var \Neos\RedirectHandler\Storage\RedirectStorageInterface $redirectStorage */
         $redirectStorage = $this->objectManager->get(\Neos\RedirectHandler\Storage\RedirectStorageInterface::class);
         foreach ($uriMapping as $originalUri => $newUri) {
             $existingRedirect = $redirectStorage->getOneBySourceUriPathAndHost($originalUri);
             if ($existingRedirect === null) {
                 $redirectStorage->addRedirect($originalUri, $newUri, 301);
             }
         }
     }
     $this->getRepository($asset)->update($asset);
     $this->emitAssetResourceReplaced($asset);
 }
 /**
  * Sets up security test requirements
  *
  * Security is based on action requests so we need a working route for the TestingProvider.
  *
  * @return void
  */
 protected function setupSecurity()
 {
     $this->securityContext = $this->objectManager->get(\Neos\Flow\Security\Context::class);
     if ($this->testableSecurityEnabled) {
         $this->privilegeManager = $this->objectManager->get(\Neos\Flow\Security\Authorization\TestingPrivilegeManager::class);
         $this->privilegeManager->setOverrideDecision(null);
         $this->policyService = $this->objectManager->get(\Neos\Flow\Security\Policy\PolicyService::class);
         $this->authenticationManager = $this->objectManager->get(\Neos\Flow\Security\Authentication\AuthenticationProviderManager::class);
         $this->testingProvider = $this->objectManager->get(\Neos\Flow\Security\Authentication\Provider\TestingProvider::class);
         $this->testingProvider->setName('TestingProvider');
         $this->registerRoute('functionaltestroute', 'typo3/flow/test', array('@package' => 'Neos.Flow', '@subpackage' => 'Tests\\Functional\\Mvc\\Fixtures', '@controller' => 'Standard', '@action' => 'index', '@format' => 'html'));
         $requestHandler = self::$bootstrap->getActiveRequestHandler();
         $actionRequest = $this->route($requestHandler->getHttpRequest());
         $this->securityContext->clearContext();
         $this->securityContext->setRequest($actionRequest);
     } else {
         \Neos\Utility\ObjectAccess::setProperty($this->securityContext, 'authorizationChecksDisabled', true, true);
     }
 }
 /**
  * Return the node label generator class for the given node
  *
  * @return NodeLabelGeneratorInterface
  */
 public function getNodeLabelGenerator()
 {
     $this->initialize();
     if ($this->nodeLabelGenerator === null) {
         if ($this->hasConfiguration('label.generatorClass')) {
             $nodeLabelGenerator = $this->objectManager->get($this->getConfiguration('label.generatorClass'));
         } elseif ($this->hasConfiguration('label') && is_string($this->getConfiguration('label'))) {
             $nodeLabelGenerator = $this->objectManager->get(\Neos\ContentRepository\Domain\Model\ExpressionBasedNodeLabelGenerator::class);
             $nodeLabelGenerator->setExpression($this->getConfiguration('label'));
         } else {
             $nodeLabelGenerator = $this->objectManager->get(\Neos\ContentRepository\Domain\Model\NodeLabelGeneratorInterface::class);
         }
         // TODO: Remove after deprecation phase of NodeDataLabelGeneratorInterface
         if ($nodeLabelGenerator instanceof NodeDataLabelGeneratorInterface) {
             $adaptor = new NodeDataLabelGeneratorAdaptor();
             $adaptor->setNodeDataLabelGenerator($nodeLabelGenerator);
             $nodeLabelGenerator = $adaptor;
         }
         $this->nodeLabelGenerator = $nodeLabelGenerator;
     }
     return $this->nodeLabelGenerator;
 }
 /**
  * Shuts down this session
  *
  * This method must not be called manually – it is invoked by Flow's object
  * management.
  *
  * @return void
  */
 public function shutdownObject()
 {
     if ($this->started === true && $this->remote === false) {
         if ($this->metaDataCache->has($this->sessionIdentifier)) {
             // Security context can't be injected and must be retrieved manually
             // because it relies on this very session object:
             $securityContext = $this->objectManager->get(Context::class);
             if ($securityContext->isInitialized()) {
                 $this->storeAuthenticatedAccountsInfo($securityContext->getAuthenticationTokens());
             }
             $this->putData('TYPO3_Flow_Object_ObjectManager', $this->objectManager->getSessionInstances());
             $this->writeSessionMetaDataCacheEntry();
         }
         $this->started = false;
         $decimals = (int) strlen(strrchr($this->garbageCollectionProbability, '.')) - 1;
         $factor = $decimals > -1 ? $decimals * 10 : 1;
         if (rand(1, 100 * $factor) <= $this->garbageCollectionProbability * $factor) {
             $this->collectGarbage();
         }
     }
     $this->request = null;
 }
 /**
  * Dispatches a signal by calling the registered Slot methods
  *
  * @param string $signalClassName Name of the class containing the signal
  * @param string $signalName Name of the signal
  * @param array $signalArguments arguments passed to the signal method
  * @return void
  * @throws Exception\InvalidSlotException if the slot is not valid
  * @api
  */
 public function dispatch($signalClassName, $signalName, array $signalArguments = [])
 {
     if (!isset($this->slots[$signalClassName][$signalName])) {
         return;
     }
     foreach ($this->slots[$signalClassName][$signalName] as $slotInformation) {
         if (isset($slotInformation['object'])) {
             $object = $slotInformation['object'];
         } elseif (substr($slotInformation['method'], 0, 2) === '::') {
             if (!isset($this->objectManager)) {
                 if (is_callable($slotInformation['class'] . $slotInformation['method'])) {
                     $object = $slotInformation['class'];
                 } else {
                     throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
                 }
             } else {
                 $object = $this->objectManager->getClassNameByObjectName($slotInformation['class']);
             }
             $slotInformation['method'] = substr($slotInformation['method'], 2);
         } else {
             if (!isset($this->objectManager)) {
                 throw new Exception\InvalidSlotException(sprintf('Cannot dispatch %s::%s to class %s. The object manager is not yet available in the Signal Slot Dispatcher and therefore it cannot dispatch classes.', $signalClassName, $signalName, $slotInformation['class']), 1298113624);
             }
             if (!$this->objectManager->isRegistered($slotInformation['class'])) {
                 throw new Exception\InvalidSlotException('The given class "' . $slotInformation['class'] . '" is not a registered object.', 1245673367);
             }
             $object = $this->objectManager->get($slotInformation['class']);
         }
         if ($slotInformation['passSignalInformation'] === true) {
             $signalArguments[] = $signalClassName . '::' . $signalName;
         }
         if (!method_exists($object, $slotInformation['method'])) {
             throw new Exception\InvalidSlotException('The slot method ' . get_class($object) . '->' . $slotInformation['method'] . '() does not exist.', 1245673368);
         }
         call_user_func_array([$object, $slotInformation['method']], $signalArguments);
     }
 }