/** * @param Message $message * @return void */ public function queue(Message $message) { /** @var EventHandlerInterface $handler */ $handler = $this->objectManager->get($message->getRecipient()); $event = $this->arraySerializer->unserialize($message->getPayload()); $handler->handle($event); }
/** * Initializes the context * * @param array $parameters Context parameters (configured through behat.yml) */ public function __construct(array $parameters) { $this->useContext('flow', new \Flowpack\Behat\Tests\Behat\FlowContext($parameters)); $this->flowContext = $this->getSubcontext('flow'); $this->objectManager = $this->flowContext->getObjectManager(); $this->accountRepository = $this->objectManager->get('TYPO3\\Flow\\Security\\AccountRepository'); }
/** * @param NodeType $nodeType * @return NodeGeneratorImplementationInterface * @throws \TYPO3\Flow\Exception */ protected function getNodeGeneratorImplementationClassByNodeType(NodeType $nodeType) { if (!isset($this->generators[(string) $nodeType]['class'])) { throw new Exception(sprintf('Unknown generator for the current Node Type (%s)', (string) $nodeType, 1391771111)); } return $this->objectManager->get($this->generators[(string) $nodeType]['class']); }
/** * Adds all validators that extend the AssetValidatorInterface. * * @return void */ protected function initializeObject() { $assetValidatorImplementationClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface('TYPO3\\Media\\Domain\\Validator\\AssetValidatorInterface'); foreach ($assetValidatorImplementationClassNames as $assetValidatorImplementationClassName) { $this->addValidator($this->objectManager->get($assetValidatorImplementationClassName)); } }
/** * Sets the pattern (match) configuration * * @param object $patternConfiguration The pattern (match) configuration * @return void */ public function setPattern($patternConfiguration) { $this->patternConfiguration = $patternConfiguration; if (isset($patternConfiguration['resolverType'])) { $this->publicKeyResolver = $this->objectManager->get($patternConfiguration['resolverType']); } }
/** * @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 = array(); foreach ($sortedChainConfiguration as $componentName => $configuration) { $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : array(); 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(array('components' => $chainComponents)); }
/** * 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('TYPO3\\Flow\\Configuration\\Source\\YamlSource'); $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('TYPO3.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES); $this->router->setRoutesConfiguration($routesConfiguration); $componentContext->setParameter('TYPO3\\Flow\\Mvc\\Routing\\RoutingComponent', 'skipRouterInitialization', TRUE); }
/** * 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)); } }
/** * @param mixed $source * @param string $targetType * @param array $convertedChildProperties * @param PropertyMappingConfigurationInterface|null $configuration * @return mixed|\Netlogix\JsonApiOrg\Schema\ResourceInterface|\TYPO3\Flow\Error\Error */ public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = null) { if (is_string($source)) { $sourceArray = json_decode($source, true); $source = is_array($sourceArray) ? $sourceArray : ['id' => $source]; } if (!array_key_exists('type', $source)) { $dummyPayload = $this->objectManager->get($targetType); $typeIdentifier = $dummyPayload->getType(); $source['type'] = $this->exposableTypeMap->getType($typeIdentifier); } if (array_key_exists('id', $source)) { $arguments = $source['id']; } else { $arguments = []; } $payload = $this->propertyMapper->convert($arguments, $this->exposableTypeMap->getClassName($source['type'])); $resourceInformation = $this->resourceMapper->findResourceInformation($payload); $resource = $resourceInformation->getResource($payload); if (isset($source['attributes'])) { $attributes = $resource->getAttributes(); foreach ($source['attributes'] as $fieldName => $value) { $attributes[$fieldName] = $value; } } if (isset($source['relationships'])) { $relationships = $resource->getRelationships(); foreach ($source['relationships'] as $fieldName => $value) { $relationships[$fieldName] = $value; } } return $resource; }
/** * Initializes the context * * @param array $parameters Context parameters (configured through behat.yml) */ public function __construct(array $parameters) { $this->useContext('flow', new \Flowpack\Behat\Tests\Behat\FlowContext($parameters)); $this->objectManager = $this->getSubcontext('flow')->getObjectManager(); $this->environment = $this->objectManager->get('TYPO3\\Flow\\Utility\\Environment'); $this->nodeAuthorizationService = $this->objectManager->get('TYPO3\\TYPO3CR\\Service\\AuthorizationService'); }
/** * Mocks an entity as wished * * @param string $fqcn the fully qualified class name * @param boolean $persist if the entity should be directly persisted or not * @param array $customProperties the properties to set if wished * @return Object */ public function create($fqcn, $persist = false, $customProperties = array()) { $entityConfiguration = $this->entityConfiguration[$fqcn]; $this->validateEntityConfiguration($fqcn, $entityConfiguration); // create from reflection class if constructor needs arguments if (!empty($entityConfiguration['constructorArguments'])) { $reflector = new \ReflectionClass($fqcn); $constructorArguments = $this->getValuesFromConfigurations($entityConfiguration['constructorArguments']); $entity = $reflector->newInstanceArgs($constructorArguments); } else { $entity = new $fqcn(); } // set the properties $configuredProperties = $entityConfiguration['properties'] ?: array(); $properties = array_merge($configuredProperties, $customProperties); foreach ($this->getValuesFromConfigurations($properties, $persist) as $propertyName => $propertyValue) { $propertyCouldBeSet = ObjectAccess::setProperty($entity, $propertyName, $propertyValue); if (!$propertyCouldBeSet) { throw new \Exception($fqcn . '::$' . $propertyName . ' could not be set to ' . print_r($propertyValue, true), 1416481470); } } // persist if wished if ($persist && is_string($entityConfiguration['repository'])) { $this->objectManager->get($entityConfiguration['repository'])->add($entity); // flush this entity here... $this->entityManager->flush($entity); // add to managed entities $identifier = $this->persistenceManager->getIdentifierByObject($entity); $this->managedEntities[$identifier] = $entity; } return $entity; }
/** * @param string $providerName The provider name as given in Settings.yaml * @throws \InvalidArgumentException * @return TokenEndpointInterface */ public function getTokenEndpointForProvider($providerName) { $tokenEndpointClassName = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, sprintf('TYPO3.Flow.security.authentication.providers.%s.providerOptions.tokenEndpointClassName', $providerName)); if ($tokenEndpointClassName === NULL) { throw new \InvalidArgumentException(sprintf('In Settings.yaml, there was no "tokenEndpointClassName" option given for the provider "%s".', $providerName), 1383743372); } return $this->objectManager->get($tokenEndpointClassName); }
/** * TODO: Document this Method! */ public function preToolbarRendering() { $dispatcher = $this->objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher'); if (method_exists($dispatcher, 'getSignals')) { $classes = $this->objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher')->getSignals(); $classes = $this->sanitize($classes); \Debug\Toolbar\Service\Collector::getModule('Signals')->getToolbar()->addText('Signals')->addBadge(count($classes))->getPopup()->addPartial('Signals', array('classes' => $classes))->getPanel()->addPartial('Signals', array('classes' => $classes)); } }
/** * This object is created very early and is part of the blacklisted "TYPO3\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(\TYPO3\Flow\Cache\CacheManager::class); $this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions'); $this->runtimeExpressions = $this->runtimeExpressionsCache->requireOnce('Flow_Aop_RuntimeExpressions'); } }
/** * @param string $annotatedTransformer Either a full qualified class name or a shortened one which is seeked in the current package. * * @throws \Flowpack\ElasticSearch\Exception * @return \Flowpack\ElasticSearch\Indexer\Object\Transform\TransformerInterface */ public function create($annotatedTransformer) { if (!class_exists($annotatedTransformer)) { $annotatedTransformer = 'Flowpack\\ElasticSearch\\Indexer\\Object\\Transform\\' . $annotatedTransformer . 'Transformer'; } $transformer = $this->objectManager->get($annotatedTransformer); if (!$transformer instanceof \Flowpack\ElasticSearch\Indexer\Object\Transform\TransformerInterface) { throw new \Flowpack\ElasticSearch\Exception(sprintf('The transformer instance "%s" does not implement the TransformerInterface.', $annotatedTransformer), 1339598316); } return $transformer; }
/** * Sets the pattern (match) configuration * * @param object $pattern The pattern (match) configuration * @return void */ public function setPattern($patternValue) { $this->patternValue = $patternValue; if (isset($patternValue['patterns'])) { foreach ($patternValue['patterns'] as $patternConfiguration) { $requestPattern = $this->objectManager->get($this->requestPatternResolver->resolveRequestPatternClass($patternConfiguration['patternType'])); $requestPattern->setPattern($patternConfiguration['patternValue']); $this->subPatterns[] = $requestPattern; } } }
/** * Create an action request from stored route match values and dispatch to that * * @param ComponentContext $componentContext * @return void */ public function handle(ComponentContext $componentContext) { $httpRequest = $componentContext->getHttpRequest(); /** @var $actionRequest ActionRequest */ $actionRequest = $this->objectManager->get(\TYPO3\Flow\Mvc\ActionRequest::class, $httpRequest); $this->securityContext->setRequest($actionRequest); $routingMatchResults = $componentContext->getParameter(\TYPO3\Flow\Mvc\Routing\RoutingComponent::class, 'matchResults'); $actionRequest->setArguments($this->mergeArguments($httpRequest, $routingMatchResults)); $this->setDefaultControllerAndActionNameIfNoneSpecified($actionRequest); $componentContext->setParameter(\TYPO3\Flow\Mvc\DispatchComponent::class, 'actionRequest', $actionRequest); $this->dispatcher->dispatch($actionRequest, $componentContext->getHttpResponse()); }
/** * 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(array($service, $methodName), $this->arguments); return true; } catch (\Exception $exception) { $this->deferMethodCallAspect->setProcessingJob(false); throw $exception; } }
/** * Synchronize designs from Flow declarations to CouchDB documents * * @return void * @author Christopher Hlubek <*****@*****.**> */ public function synchronizeCommand() { $designDocumentClassNames = $this->reflectionService->getAllSubClassNamesForClass('TYPO3\\CouchDB\\DesignDocument'); foreach ($designDocumentClassNames as $objectName) { if ($this->objectManager->getScope($objectName) === \TYPO3\Flow\Object\Configuration\Configuration::SCOPE_SINGLETON) { $designDocument = $this->objectManager->get($objectName); $designDocument->synchronize(); $this->outputLine($objectName . ' synchronized.'); } else { $this->outputLine($objectName . ' skipped.'); } } }
/** * Around advice, wrapping every method of a scope session object. It redirects * all method calls to the session object once there is one. * * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return mixed * @Flow\Around("filter(TYPO3\Flow\Session\Aspect\SessionObjectMethodsPointcutFilter)") */ public function callMethodOnOriginalSessionObject(\TYPO3\Flow\Aop\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(array($this->sessionOriginalInstances[$objectName], $methodName), $joinPoint->getMethodArguments()); } }
/** * @return SubProcess */ protected function getSubProcess() { if ($this->subProcess === NULL) { /** @var CacheManager $cacheManager */ $cacheManager = $this->objectManager->get('TYPO3\\Flow\\Cache\\CacheManager'); if ($cacheManager->hasCache('Flow_Security_Policy_Privilege_Method')) { $cacheManager->getCache('Flow_Security_Policy_Privilege_Method')->flush(); } $objectConfigurationCache = $cacheManager->getCache('Flow_Object_Configuration'); $objectConfigurationCache->remove('allAspectClassesUpToDate'); $objectConfigurationCache->remove('allCompiledCodeUpToDate'); $cacheManager->getCache('Flow_Object_Classes')->flush(); $this->subProcess = new SubProcess($this->objectManager->getContext()); } return $this->subProcess; }
/** * 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 \TYPO3\Flow\Aop\JoinPointInterface $joinPoint * @return void * @Flow\Signal */ protected function emitAdviceInvoked($aspectObject, $methodName, $joinPoint) { if ($this->dispatcher === null) { $this->dispatcher = $this->objectManager->get(\TYPO3\Flow\SignalSlot\Dispatcher::class); } $this->dispatcher->dispatch(\TYPO3\Flow\Aop\Advice\AbstractAdvice::class, 'adviceInvoked', array($aspectObject, $methodName, $joinPoint)); }
/** * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext * @return void * @throws \TYPO3\Setup\Exception */ public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext) { $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues(); if (isset($formValues['prune']) && intval($formValues['prune']) === 1) { $this->nodeDataRepository->removeAll(); $this->workspaceRepository->removeAll(); $this->domainRepository->removeAll(); $this->siteRepository->removeAll(); $this->persistenceManager->persistAll(); } if (!empty($formValues['packageKey'])) { if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) { throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486); } $packageKey = $formValues['packageKey']; $siteName = $formValues['siteName']; $generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService'); $generatorService->generateSitePackage($packageKey, $siteName); } elseif (!empty($formValues['site'])) { $packageKey = $formValues['site']; } $this->deactivateOtherSitePackages($packageKey); $this->packageManager->activatePackage($packageKey); if (!empty($packageKey)) { try { $contentContext = $this->contextFactory->create(array('workspaceName' => 'live')); $this->siteImportService->importFromPackage($packageKey, $contentContext); } catch (\Exception $exception) { $finisherContext->cancel(); $this->systemLogger->logException($exception); throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864); } } }
/** * 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 \TYPO3\Flow\Aop\JoinPointInterface $joinPoint * @return void * @Flow\Signal */ protected function emitAdviceInvoked($aspectObject, $methodName, $joinPoint) { if ($this->dispatcher === NULL) { $this->dispatcher = $this->objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher'); } $this->dispatcher->dispatch('TYPO3\\Flow\\Aop\\Advice\\AbstractAdvice', 'adviceInvoked', array($aspectObject, $methodName, $joinPoint)); }
/** * Handle an Exception thrown while rendering TypoScript according to * settings specified in TYPO3.TypoScript.rendering.exceptionHandler * * @param array $typoScriptPath * @param \Exception $exception * @param boolean $useInnerExceptionHandler * @return string * @throws \TYPO3\Flow\Mvc\Exception\StopActionException * @throws \TYPO3\Flow\Configuration\Exception\InvalidConfigurationException * @throws \Exception|\TYPO3\Flow\Exception */ 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 "TYPO3.TypoScript.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, 'TYPO3\\TypoScript\\Core\\ExceptionHandlers'); throw new \TYPO3\Flow\Configuration\Exception\InvalidConfigurationException($message, 1368788926); } $exceptionHandler->setRuntime($this); if (array_key_exists('__objectType', $typoScriptConfiguration)) { $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']); } $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception); return $output; }
/** * @param array $humanReadableContextProperties * @param boolean $addDimensionDefaults * @return \TYPO3\TYPO3CR\Domain\Service\Context */ protected function getContextForProperties(array $humanReadableContextProperties, $addDimensionDefaults = FALSE) { /** @var \TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface $contextFactory */ $contextFactory = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface'); $contextProperties = array(); if (isset($humanReadableContextProperties['Locale'])) { $contextProperties['dimensions']['locales'] = array($humanReadableContextProperties['Locale'], 'mul_ZZ'); } if (isset($humanReadableContextProperties['Locales'])) { $contextProperties['dimensions']['locales'] = Arrays::trimExplode(',', $humanReadableContextProperties['Locales']); } if (isset($humanReadableContextProperties['Workspace'])) { $contextProperties['workspaceName'] = $humanReadableContextProperties['Workspace']; } foreach ($humanReadableContextProperties as $propertyName => $propertyValue) { // Set flexible dimensions from features if (strpos($propertyName, 'Dimension: ') === 0) { $contextProperties['dimensions'][substr($propertyName, strlen('Dimension: '))] = Arrays::trimExplode(',', $propertyValue); } if (strpos($propertyName, 'Target dimension: ') === 0) { $contextProperties['targetDimensions'][substr($propertyName, strlen('Target dimension: '))] = $propertyValue; } } if ($addDimensionDefaults) { $contentDimensionRepository = $this->objectManager->get('TYPO3\\TYPO3CR\\Domain\\Repository\\ContentDimensionRepository'); $availableDimensions = $contentDimensionRepository->findAll(); foreach ($availableDimensions as $dimension) { if (isset($contextProperties['dimensions'][$dimension->getIdentifier()]) && !in_array($dimension->getDefault(), $contextProperties['dimensions'][$dimension->getIdentifier()])) { $contextProperties['dimensions'][$dimension->getIdentifier()][] = $dimension->getDefault(); } } } return $contextFactory->create($contextProperties); }
/** * Convert array to change interface * * @param array $changeData * @return ChangeInterface */ protected function convertChangeData($changeData) { $type = $changeData['type']; if (!isset($this->typeMap[$type])) { return new \TYPO3\Flow\Error\Error(sprintf('Could not convert change type %s, it is unknown to the system', $type)); } $changeClass = $this->typeMap[$type]; $changeClassInstance = $this->objectManager->get($changeClass); $subjectContextPath = $changeData['subject']; $subject = $this->nodeService->getNodeFromContextPath($subjectContextPath); if ($subject instanceof \TYPO3\Flow\Error\Error) { return $subject; } $changeClassInstance->setSubject($subject); if (isset($changeData['reference']) && method_exists($changeClassInstance, 'setReference')) { $referenceContextPath = $changeData['reference']; $reference = $this->nodeService->getNodeFromContextPath($referenceContextPath); if ($reference instanceof \TYPO3\Flow\Error\Error) { return $reference; } $changeClassInstance->setReference($reference); } if (isset($changeData['payload'])) { foreach ($changeData['payload'] as $key => $value) { if (!in_array($key, $this->disallowedPayloadProperties)) { ObjectAccess::setProperty($changeClassInstance, $key, $value); } } } return $changeClassInstance; }
/** * Looks for URIs pointing to package resources and in place of those adds * ViewHelperNode instances using the ResourceViewHelper. * * @param NodeInterface $node * @param integer $interceptorPosition One of the INTERCEPT_* constants for the current interception point * @param ParsingState $parsingState the current parsing state. Not needed in this interceptor. * @return NodeInterface the modified node */ public function process(NodeInterface $node, $interceptorPosition, ParsingState $parsingState) { /** @var $node TextNode */ if (strpos($node->getText(), 'Public/') === FALSE) { return $node; } $textParts = preg_split(self::PATTERN_SPLIT_AT_RESOURCE_URIS, $node->getText(), -1, PREG_SPLIT_DELIM_CAPTURE); $node = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\RootNode'); foreach ($textParts as $part) { $matches = array(); if (preg_match(self::PATTERN_MATCH_RESOURCE_URI, $part, $matches)) { $arguments = array('path' => $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', $matches['Path'])); if (isset($matches['Package']) && preg_match(Package::PATTERN_MATCH_PACKAGEKEY, $matches['Package'])) { $arguments['package'] = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', $matches['Package']); } elseif ($this->defaultPackageKey !== NULL) { $arguments['package'] = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', $this->defaultPackageKey); } $viewHelper = $this->objectManager->get('TYPO3\\Fluid\\ViewHelpers\\Uri\\ResourceViewHelper'); /** @var $viewHelperNode ViewHelperNode */ $viewHelperNode = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', $viewHelper, $arguments); $node->addChildNode($viewHelperNode); } else { /** @var $textNode TextNode */ $textNode = $this->objectManager->get('TYPO3\\Fluid\\Core\\Parser\\SyntaxTree\\TextNode', $part); $node->addChildNode($textNode); } } return $node; }
/** * 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 = array(); 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); return $this->getObjectValueByPath($globalObject, $objectAccess[2]); } else { return trim($expression, '"\''); } }
/** * 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 = array(); 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, '"\''); } }