/**
  * @return void
  */
 protected function initializeAction()
 {
     $this->objects = $this->widgetConfiguration['objects'];
     $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], true);
     $this->numberOfPages = (int) ceil(count($this->objects) / (int) $this->configuration['itemsPerPage']);
     $this->maximumNumberOfLinks = (int) $this->configuration['maximumNumberOfLinks'];
 }
Example #2
0
 /**
  *
  * @param string $type
  * @param boolean $showHiddenProperties if TRUE, the hidden properties are shown as configured in settings "supertypeResolver.hiddenProperties" are shown as well. FALSE by default
  * @return array
  * @throws \TYPO3\Form\Exception\TypeDefinitionNotFoundException if a type definition was not found
  * @internal
  */
 public function getMergedTypeDefinition($type, $showHiddenProperties = FALSE)
 {
     if (!isset($this->configuration[$type])) {
         throw new \TYPO3\Form\Exception\TypeDefinitionNotFoundException(sprintf('Type "%s" not found. Probably some configuration is missing.', $type), 1325686909);
     }
     $mergedTypeDefinition = array();
     if (isset($this->configuration[$type]['superTypes'])) {
         foreach ($this->configuration[$type]['superTypes'] as $superTypeName => $enabled) {
             // Skip unset node types
             if ($enabled === FALSE || $enabled === NULL) {
                 continue;
             }
             // Make this setting backwards compatible with old array schema (deprecated since 2.0)
             if (!is_bool($enabled)) {
                 $superTypeName = $enabled;
             }
             $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->getMergedTypeDefinition($superTypeName, $showHiddenProperties));
         }
     }
     $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->configuration[$type]);
     unset($mergedTypeDefinition['superTypes']);
     if ($showHiddenProperties === FALSE && isset($this->settings['supertypeResolver']['hiddenProperties']) && is_array($this->settings['supertypeResolver']['hiddenProperties'])) {
         foreach ($this->settings['supertypeResolver']['hiddenProperties'] as $propertyName) {
             unset($mergedTypeDefinition[$propertyName]);
         }
     }
     return $mergedTypeDefinition;
 }
 /**
  * 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 string $version
  * @param boolean $loadJQuery
  * @param boolean $loadEmberData
  * @param boolean $minified
  * @return string
  * @throws \Exception
  */
 public function render($version = NULL, $loadJQuery = FALSE, $loadEmberData = FALSE, $minified = TRUE)
 {
     $defaults = $this->getConfigurationArray('defaults', $version, $minified);
     $version = $this->findVersionToLoad($version);
     // Make sure the requested version has Ember-data configured
     if ($loadEmberData && $this->settings['versions'][$version]['hasData'] === FALSE) {
         throw new \Exception(sprintf('Version %s has no Ember-data configured', $version));
     }
     // Merge defaults and version configuration (version configuration overrides defaults)
     $configuration = Arrays::arrayMergeRecursiveOverrule($defaults, $this->getConfigurationArray($version, $version, $minified), FALSE, FALSE);
     // Remove jQuery
     if ($loadJQuery === FALSE && isset($configuration['requirements']['jquery'])) {
         unset($configuration['requirements']['jquery']);
     }
     // Build the includes array
     $includes = array();
     foreach ($configuration['requirements'] as $requirement) {
         $includes[] = $requirement['path'];
     }
     $includes[] = $this->getResourcePath($this->settings['paths']['ember'], $version, $minified);
     if ($loadEmberData === TRUE) {
         $includes[] = $this->getResourcePath($this->settings['paths']['ember-data'], $version, $minified);
     }
     // Generate script tags
     $baseUrl = $this->resourcePublisher->getStaticResourcesWebBaseUri();
     $includes = array_map(function ($file) use($baseUrl) {
         return sprintf('<script src="%sPackages/%s"></script>', $baseUrl, $file);
     }, $includes);
     return implode('', $includes);
 }
Example #5
0
 /**
  * Construct a couch DB connection from basic connection parameters for one
  * given database.
  *
  * @param string $host
  * @param integer $port
  * @param string $username
  * @param string $password
  * @param array $options
  */
 public function __construct($host, $port = 5984, $username = NULL, $password = NULL, array $options = array())
 {
     $this->options['host'] = (string) $host;
     $this->options['port'] = (int) $port;
     $this->options['username'] = $username;
     $this->options['password'] = $password;
     $this->options = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->options, $options, TRUE);
 }
 /**
  * Merges the given context properties with sane defaults for the context implementation.
  *
  * @param array $contextProperties
  * @return array
  */
 protected function mergeContextPropertiesWithDefaults(array $contextProperties)
 {
     $contextProperties = $this->removeDeprecatedProperties($contextProperties);
     $defaultContextProperties = array('workspaceName' => 'live', 'currentDateTime' => $this->now, 'dimensions' => array(), 'targetDimensions' => array(), 'invisibleContentShown' => FALSE, 'removedContentShown' => FALSE, 'inaccessibleContentShown' => FALSE, 'currentSite' => NULL, 'currentDomain' => NULL);
     $mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, TRUE);
     $this->mergeDimensionValues($contextProperties, $mergedProperties);
     $this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
     return $mergedProperties;
 }
Example #7
0
 /**
  * @param Request $httpRequest
  * @param array $matchResults
  * @return ActionRequest
  */
 protected function createActionRequest(Request $httpRequest, array $matchResults = NULL)
 {
     $actionRequest = new ActionRequest($httpRequest);
     if ($matchResults !== NULL) {
         $requestArguments = $actionRequest->getArguments();
         $mergedArguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $matchResults);
         $actionRequest->setArguments($mergedArguments);
     }
     return $actionRequest;
 }
 /**
  * Executes this task
  *
  * @param \TYPO3\Surf\Domain\Model\Node $node
  * @param \TYPO3\Surf\Domain\Model\Application $application
  * @param \TYPO3\Surf\Domain\Model\Deployment $deployment
  * @param array $options
  * @return void
  * @throws \TYPO3\Surf\Exception\TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     parent::execute($node, $application, $deployment, $options);
     $settingsPatch = \Symfony\Component\Yaml\Yaml::parse(file_get_contents($this->resourcePath . '/Settings.yaml'));
     $settings = (array) \Symfony\Component\Yaml\Yaml::parse(FLOW_PATH_ROOT . '/Configuration/Settings.yaml');
     $settings = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($settings, $settingsPatch);
     $patchedSettings = $this->temporaryPath . '/Settings.yaml';
     file_put_contents($patchedSettings, \Symfony\Component\Yaml\Yaml::dump($settings, 999));
     $patchedSettingsTargetPath = $deployment->getApplicationReleasePath($application) . '/Configuration/Settings.yaml';
     $this->copy($patchedSettings, $patchedSettingsTargetPath);
 }
 /**
  * @test
  */
 public function ignoredClassesCanBeOverwrittenBySettings()
 {
     $object = new ApplicationContext('Development');
     $this->assertEquals('TYPO3\\Flow\\Core\\ApplicationContext prototype object', Debugger::renderDump($object, 10, TRUE));
     Debugger::clearState();
     $currentConfiguration = ObjectAccess::getProperty($this->configurationManager, 'configurations', TRUE);
     $configurationOverwrite['Settings']['TYPO3']['Flow']['error']['debugger']['ignoredClasses']['TYPO3\\\\Flow\\\\Core\\\\.*'] = FALSE;
     $newConfiguration = Arrays::arrayMergeRecursiveOverrule($currentConfiguration, $configurationOverwrite);
     ObjectAccess::setProperty($this->configurationManager, 'configurations', $newConfiguration, TRUE);
     $this->assertContains('rootContextString', Debugger::renderDump($object, 10, TRUE));
 }
Example #10
0
 /**
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render($persistenceIdentifier = NULL, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = array())
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     return $form->render();
 }
 /**
  * Merges the given context properties with sane defaults for the context implementation.
  *
  * @param array $contextProperties
  * @return array
  */
 protected function mergeContextPropertiesWithDefaults(array $contextProperties)
 {
     $contextProperties = $this->removeDeprecatedProperties($contextProperties);
     $defaultContextProperties = array('workspaceName' => 'live', 'currentDateTime' => $this->now, 'dimensions' => array(), 'targetDimensions' => array(), 'invisibleContentShown' => false, 'removedContentShown' => false, 'inaccessibleContentShown' => false, 'currentSite' => null, 'currentDomain' => null);
     if (!isset($contextProperties['currentSite'])) {
         $defaultContextProperties = $this->setDefaultSiteAndDomainFromCurrentRequest($defaultContextProperties);
     }
     $mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, true);
     $this->mergeDimensionValues($contextProperties, $mergedProperties);
     $this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
     return $mergedProperties;
 }
 /**
  * @param string $grantType One of this' interface GRANT_TYPE_* constants
  * @param array $additionalParameters Additional parameters for the request
  * @return mixed
  * @throws \Flowpack\OAuth2\Client\Exception
  * @see http://tools.ietf.org/html/rfc6749#section-4.1.3
  */
 protected function requestAccessToken($grantType, $additionalParameters = array())
 {
     $parameters = array('grant_type' => $grantType, 'client_id' => $this->clientIdentifier, 'client_secret' => $this->clientSecret);
     $parameters = Arrays::arrayMergeRecursiveOverrule($parameters, $additionalParameters, FALSE, FALSE);
     $request = Request::create(new Uri($this->endpointUri), 'POST', $parameters);
     $request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
     $response = $this->requestEngine->sendRequest($request);
     if ($response->getStatusCode() !== 200) {
         throw new OAuth2Exception(sprintf('The response when requesting the access token was not as expected, code and message was: %d %s', $response->getStatusCode(), $response->getContent()), 1383749757);
     }
     $responseComponents = json_decode($response->getContent(), true);
     return $responseComponents['access_token'];
 }
 /**
  * @return void
  */
 protected function initializeAction()
 {
     $this->parentNode = $this->widgetConfiguration['parentNode'];
     $this->nodes = $this->widgetConfiguration['nodes'];
     $this->nodeTypeFilter = $this->widgetConfiguration['nodeTypeFilter'] ?: null;
     $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], true);
     $this->maximumNumberOfNodes = $this->configuration['maximumNumberOfNodes'];
     $numberOfNodes = $this->parentNode === null ? count($this->nodes) : $this->parentNode->getNumberOfChildNodes($this->nodeTypeFilter);
     if ($this->maximumNumberOfNodes > 0 && $numberOfNodes > $this->maximumNumberOfNodes) {
         $numberOfNodes = $this->maximumNumberOfNodes;
     }
     $this->numberOfPages = ceil($numberOfNodes / (int) $this->configuration['itemsPerPage']);
     $this->maximumNumberOfLinks = (int) $this->configuration['maximumNumberOfLinks'];
 }
 /**
  * @param JobConfigurationInterface $jobConfiguration
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render(JobConfigurationInterface $jobConfiguration, $persistenceIdentifier = null, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = [])
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     /** @var FormDefinition $formDefinition */
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     ObjectAccess::setProperty($formDefinition, 'identifier', 'options', true);
     $this->postProcessFormDefinition($jobConfiguration, $formDefinition);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     $form->getRequest()->setArgumentNamespace('--options');
     return $form->render();
 }
 /**
  * Merges the TYPO3.Ice settings with the current settings before calling the render() method
  *
  * @return string
  */
 public function initializeArgumentsAndRender()
 {
     $settings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Ice');
     if ($this->controllerContext->getRequest()->getControllerPackageKey() !== 'TYPO3.Ice') {
         $packageSettings = $this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->controllerContext->getRequest()->getControllerPackageKey());
         if (!empty($packageSettings['extendIceSettings'])) {
             $settings = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($settings, $packageSettings);
         } else {
             $settings = $packageSettings;
         }
     }
     if (isset($settings['projectElementTypes'])) {
         $supertypeResolver = new \TYPO3\Ice\Utility\SupertypeResolver($settings['projectElementTypes']);
         $settings['projectElementTypes'] = $supertypeResolver->getCompleteMergedTypeDefinition(TRUE);
     }
     $this->settings = $settings;
     return parent::initializeArgumentsAndRender();
 }
 /**
  *
  * @param string $objectName
  * @param array $overrideProperties
  * @param boolean $addObjectToPersistence
  * @return object
  */
 public function buildObject($objectName, $overrideProperties = array(), $addObjectToPersistence = FALSE)
 {
     if (!isset($this->fixtureDefinitions[$objectName])) {
         throw new \Exception('Object name ' . $objectName . ' not configured in fixture definitions');
     }
     $properties = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->fixtureDefinitions[$objectName], $overrideProperties);
     $className = isset($properties['__type']) ? $properties['__type'] : $this->baseType;
     unset($properties['__type']);
     $object = new $className();
     foreach ($properties as $propertyName => $propertyValue) {
         if (\TYPO3\Flow\Reflection\ObjectAccess::isPropertySettable($object, $propertyName)) {
             \TYPO3\Flow\Reflection\ObjectAccess::setProperty($object, $propertyName, $propertyValue);
         }
     }
     $this->setCustomProperties($object, $properties, $addObjectToPersistence);
     if ($addObjectToPersistence) {
         $this->addObjectToPersistence($object);
     }
     return $object;
 }
Example #17
0
 /**
  *
  * @param string $type
  * @param boolean $showHiddenProperties if TRUE, the hidden properties are shown as configured in settings "supertypeResolver.hiddenProperties" are shown as well. FALSE by default
  * @return array
  * @throws \TYPO3\Ice\Exception\TypeDefinitionNotFoundException if a type definition was not found
  * @internal
  */
 public function getMergedTypeDefinition($type, $showHiddenProperties = FALSE)
 {
     if (isset($this->configuration[$type])) {
         $mergedTypeDefinition = array();
         if (isset($this->configuration[$type]['superTypes'])) {
             foreach ($this->configuration[$type]['superTypes'] as $superType) {
                 $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->getMergedTypeDefinition($superType, $showHiddenProperties));
             }
         }
         $mergedTypeDefinition = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($mergedTypeDefinition, $this->configuration[$type]);
         unset($mergedTypeDefinition['superTypes']);
         if ($showHiddenProperties === FALSE && isset($this->settings['supertypeResolver']['hiddenProperties']) && is_array($this->settings['supertypeResolver']['hiddenProperties'])) {
             foreach ($this->settings['supertypeResolver']['hiddenProperties'] as $propertyName) {
                 unset($mergedTypeDefinition[$propertyName]);
             }
         }
         return $mergedTypeDefinition;
     } else {
         throw new \TYPO3\Ice\Exception\TypeDefinitionNotFoundException(sprintf('Type "%s" not found. Probably some configuration is missing.', $type), 1325686909);
     }
 }
 /**
  * Returns an ActionRequest which referred to this request, if any.
  *
  * The referring request is not set or determined automatically but must be
  * explicitly set through the corresponding internal argument "__referrer".
  * This mechanism is used by Flow's form and validation mechanisms.
  *
  * @return ActionRequest the referring request, or NULL if no referrer found
  */
 public function getReferringRequest()
 {
     if ($this->referringRequest !== null) {
         return $this->referringRequest;
     }
     if (!isset($this->internalArguments['__referrer'])) {
         return null;
     }
     if (is_array($this->internalArguments['__referrer'])) {
         $referrerArray = $this->internalArguments['__referrer'];
         $referringRequest = new ActionRequest($this->getHttpRequest());
         $arguments = array();
         if (isset($referrerArray['arguments'])) {
             $serializedArgumentsWithHmac = $referrerArray['arguments'];
             $serializedArguments = $this->hashService->validateAndStripHmac($serializedArgumentsWithHmac);
             $arguments = unserialize(base64_decode($serializedArguments));
             unset($referrerArray['arguments']);
         }
         $referringRequest->setArguments(Arrays::arrayMergeRecursiveOverrule($arguments, $referrerArray));
         return $referringRequest;
     } else {
         $this->referringRequest = $this->internalArguments['__referrer'];
     }
     return $this->referringRequest;
 }
 /**
  * Loads the specified configuration file and returns its content as an
  * array. If the file does not exist or could not be loaded, an empty
  * array is returned
  *
  * @param string $pathAndFilename Full path and filename of the file to load, excluding the file extension (ie. ".yaml")
  * @param boolean $allowSplitSource If TRUE, the type will be used as a prefix when looking for configuration files
  * @return array
  * @throws \TYPO3\Flow\Configuration\Exception\ParseErrorException
  */
 public function load($pathAndFilename, $allowSplitSource = false)
 {
     $pathsAndFileNames = array($pathAndFilename . '.yaml');
     if ($allowSplitSource === true) {
         $splitSourcePathsAndFileNames = glob($pathAndFilename . '.*.yaml');
         if ($splitSourcePathsAndFileNames !== false) {
             sort($splitSourcePathsAndFileNames);
             $pathsAndFileNames = array_merge($pathsAndFileNames, $splitSourcePathsAndFileNames);
         }
     }
     $configuration = array();
     foreach ($pathsAndFileNames as $pathAndFilename) {
         if (is_file($pathAndFilename)) {
             try {
                 if ($this->usePhpYamlExtension) {
                     $loadedConfiguration = @yaml_parse_file($pathAndFilename);
                     if ($loadedConfiguration === false) {
                         throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
                     }
                 } else {
                     $loadedConfiguration = Yaml::parse($pathAndFilename);
                 }
                 if (is_array($loadedConfiguration)) {
                     $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
                 }
             } catch (\TYPO3\Flow\Error\Exception $exception) {
                 throw new \TYPO3\Flow\Configuration\Exception\ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
             }
         }
     }
     return $configuration;
 }
 /**
  * Return the mapping which would be sent to the server as array
  *
  * @return array
  */
 public function asArray()
 {
     return array($this->type->getName() => Arrays::arrayMergeRecursiveOverrule(array('dynamic_templates' => $this->getDynamicTemplates(), 'properties' => $this->getProperties()), $this->fullMapping));
 }
 /**
  * @param string $nodeTypeName
  * @param array $configuration
  * @throws \TYPO3\Neos\Exception
  * @return void
  */
 protected function addEditorDefaultsToNodeTypeConfiguration($nodeTypeName, &$configuration)
 {
     if (isset($configuration['properties']) && is_array($configuration['properties'])) {
         foreach ($configuration['properties'] as $propertyName => &$propertyConfiguration) {
             if (!isset($propertyConfiguration['type'])) {
                 continue;
             }
             $type = $propertyConfiguration['type'];
             if (!isset($this->dataTypesDefaultConfiguration[$type])) {
                 continue;
             }
             if (!isset($propertyConfiguration['ui']['inspector'])) {
                 continue;
             }
             $defaultConfigurationFromDataType = $this->dataTypesDefaultConfiguration[$type];
             // FIRST STEP: Figure out which editor should be used
             // - Default: editor as configured from the data type
             // - Override: editor as configured from the property configuration.
             if (isset($propertyConfiguration['ui']['inspector']['editor'])) {
                 $editor = $propertyConfiguration['ui']['inspector']['editor'];
             } elseif (isset($defaultConfigurationFromDataType['editor'])) {
                 $editor = $defaultConfigurationFromDataType['editor'];
             } else {
                 throw new \TYPO3\Neos\Exception('Could not find editor for ' . $propertyName . ' in node type ' . $nodeTypeName, 1436809123);
             }
             // SECOND STEP: Build up the full inspector configuration by merging:
             // - take configuration from editor defaults
             // - take configuration from dataType
             // - take configuration from properties (NodeTypes)
             $mergedInspectorConfiguration = array();
             if (isset($this->editorDefaultConfiguration[$editor])) {
                 $mergedInspectorConfiguration = $this->editorDefaultConfiguration[$editor];
             }
             $mergedInspectorConfiguration = Arrays::arrayMergeRecursiveOverrule($mergedInspectorConfiguration, $defaultConfigurationFromDataType);
             $mergedInspectorConfiguration = Arrays::arrayMergeRecursiveOverrule($mergedInspectorConfiguration, $propertyConfiguration['ui']['inspector']);
             $propertyConfiguration['ui']['inspector'] = $mergedInspectorConfiguration;
             $propertyConfiguration['ui']['inspector']['editor'] = $editor;
         }
     }
 }
 /**
  * Set the "context node" this operation was working on.
  *
  * @param NodeInterface $node
  * @return void
  */
 public function setNode(NodeInterface $node)
 {
     $this->nodeIdentifier = $node->getIdentifier();
     $this->workspaceName = $node->getContext()->getWorkspaceName();
     $this->dimension = $node->getContext()->getDimensions();
     $context = $node->getContext();
     if ($context instanceof ContentContext && $context->getCurrentSite() !== null) {
         $siteIdentifier = $this->persistenceManager->getIdentifierByObject($context->getCurrentSite());
     } else {
         $siteIdentifier = null;
     }
     $this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('nodeContextPath' => $node->getContextPath(), 'nodeLabel' => $node->getLabel(), 'nodeType' => $node->getNodeType()->getName(), 'site' => $siteIdentifier));
     $node = self::getClosestAggregateNode($node);
     if ($node !== null) {
         $this->documentNodeIdentifier = $node->getIdentifier();
         $this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('documentNodeContextPath' => $node->getContextPath(), 'documentNodeLabel' => $node->getLabel(), 'documentNodeType' => $node->getNodeType()->getName()));
     }
 }
 /**
  * Initialize action, and merge settings if needed
  *
  * @return void
  */
 public function initializeAction()
 {
     if ($this->request->getControllerPackageKey() !== 'TYPO3.Ice' && !empty($this->settings['extendIceSettings'])) {
         $this->settings = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Ice'), $this->settings);
     }
 }
 /**
  * @param array $contextProperties
  * @param array $mergedProperties
  * @return void
  * @throws InvalidNodeContextException
  */
 protected function mergeDimensionValues(array $contextProperties, array &$mergedProperties)
 {
     $dimensions = $this->getAvailableDimensions();
     foreach ($dimensions as $dimension) {
         /** @var ContentDimension $dimension */
         $identifier = $dimension->getIdentifier();
         $values = array($dimension->getDefault());
         if (isset($contextProperties['dimensions'][$identifier])) {
             if (!is_array($contextProperties['dimensions'][$identifier])) {
                 throw new InvalidNodeContextException(sprintf('The given dimension fallback chain for "%s" should be an array of string, but "%s" was given.', $identifier, gettype($contextProperties['dimensions'][$identifier])), 1407417930);
             }
             $values = Arrays::arrayMergeRecursiveOverrule($values, $contextProperties['dimensions'][$identifier]);
         }
         $mergedProperties['dimensions'][$identifier] = $values;
     }
 }
 /**
  * Tries to load the reflection data from the compile time cache.
  *
  * The compile time cache is only supported for Development context and thus
  * this function will return in any other context.
  *
  * If no reflection data was found, this method will at least load the precompiled
  * reflection data of any possible frozen package. Even if precompiled reflection
  * data could be loaded, FALSE will be returned in order to signal that other
  * packages still need to be reflected.
  *
  * @return boolean TRUE if reflection data could be loaded, otherwise FALSE
  */
 protected function loadClassReflectionCompiletimeCache()
 {
     $data = $this->reflectionDataCompiletimeCache->get('ReflectionData');
     if ($data !== false) {
         foreach ($data as $propertyName => $propertyValue) {
             $this->{$propertyName} = $propertyValue;
         }
         return true;
     }
     if (!$this->context->isDevelopment()) {
         return false;
     }
     $useIgBinary = extension_loaded('igbinary');
     foreach ($this->packageManager->getActivePackages() as $packageKey => $package) {
         if (!$this->packageManager->isPackageFrozen($packageKey)) {
             continue;
         }
         $pathAndFilename = $this->getPrecompiledReflectionStoragePath() . $packageKey . '.dat';
         if (!file_exists($pathAndFilename)) {
             continue;
         }
         $data = $useIgBinary ? igbinary_unserialize(file_get_contents($pathAndFilename)) : unserialize(file_get_contents($pathAndFilename));
         foreach ($data as $propertyName => $propertyValue) {
             $this->{$propertyName} = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($this->{$propertyName}, $propertyValue);
         }
     }
     return false;
 }
Example #26
0
 /**
  * @param array $properties
  */
 public function __construct(array $properties)
 {
     $this->properties = Arrays::arrayMergeRecursiveOverrule($this->properties, $properties);
 }
 /**
  * Tries to load the 'TYPO3.Flow.error.debugger.ignoredClasses' setting
  * to build a regular expression that can be used to filter ignored class names
  * If settings can't be loaded it uses self::$ignoredClassesFallback.
  *
  * @return string
  */
 public static function getIgnoredClassesRegex()
 {
     if (self::$ignoredClassesRegex !== '') {
         return self::$ignoredClassesRegex;
     }
     $ignoredClassesConfiguration = self::$ignoredClassesFallback;
     $ignoredClasses = array();
     if (self::$objectManager instanceof ObjectManagerInterface) {
         $configurationManager = self::$objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
         if ($configurationManager instanceof ConfigurationManager) {
             $ignoredClassesFromSettings = $configurationManager->getConfiguration('Settings', 'TYPO3.Flow.error.debugger.ignoredClasses');
             if (is_array($ignoredClassesFromSettings)) {
                 $ignoredClassesConfiguration = Arrays::arrayMergeRecursiveOverrule($ignoredClassesConfiguration, $ignoredClassesFromSettings);
             }
         }
     }
     foreach ($ignoredClassesConfiguration as $classNamePattern => $active) {
         if ($active === TRUE) {
             $ignoredClasses[] = $classNamePattern;
         }
     }
     self::$ignoredClassesRegex = sprintf('/^%s$/xs', implode('$|^', $ignoredClasses));
     return self::$ignoredClassesRegex;
 }
 /**
  * Will get called by the constructor to initialize this view.
  *
  * @return void
  */
 public function initializeReport($reportKey)
 {
     $this->configuration = Arrays::arrayMergeRecursiveOverrule($this->settings['General'], $this->settings[$reportKey]);
     $this->setContentTypeHeader();
     $this->setContentDispositionHeader();
 }
 /**
  * Return the json array for a given locale, sourceCatalog, xliffPath and package.
  * The json will be cached.
  *
  * @param Locale $locale The locale
  * @return Result
  * @throws Exception
  */
 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;
 }
 /**
  * Assigns a value to a node or a property in the object tree, specified by the object path array.
  *
  * @param array $objectPathArray The object path, specifying the node / property to set
  * @param mixed $value The value to assign, is a non-array type or an array with __eelExpression etc.
  * @param array $objectTree The current (sub-) tree, used internally - don't specify!
  * @return array The modified object tree
  */
 protected function setValueInObjectTree(array $objectPathArray, $value, &$objectTree = null)
 {
     if ($objectTree === null) {
         $objectTree =& $this->objectTree;
     }
     $currentKey = array_shift($objectPathArray);
     if ((int) $currentKey > 0) {
         $currentKey = (int) $currentKey;
     }
     if (empty($objectPathArray)) {
         // last part of the iteration, setting the final value
         if (isset($objectTree[$currentKey]) && $value === null) {
             unset($objectTree[$currentKey]);
         } elseif (isset($objectTree[$currentKey]) && is_array($objectTree[$currentKey])) {
             if (is_array($value)) {
                 $objectTree[$currentKey] = \TYPO3\Flow\Utility\Arrays::arrayMergeRecursiveOverrule($objectTree[$currentKey], $value);
             } else {
                 $objectTree[$currentKey]['__value'] = $value;
                 $objectTree[$currentKey]['__eelExpression'] = null;
                 $objectTree[$currentKey]['__objectType'] = null;
             }
         } else {
             $objectTree[$currentKey] = $value;
         }
     } else {
         // we still need to traverse further down
         if (isset($objectTree[$currentKey]) && !is_array($objectTree[$currentKey])) {
             // the element one-level-down is already defined, but it is NOT an array. So we need to convert the simple type to __value
             $objectTree[$currentKey] = array('__value' => $objectTree[$currentKey], '__eelExpression' => null, '__objectType' => null);
         } elseif (!isset($objectTree[$currentKey])) {
             $objectTree[$currentKey] = array();
         }
         $this->setValueInObjectTree($objectPathArray, $value, $objectTree[$currentKey]);
     }
     return $objectTree;
 }