/** * @param array $module * @return void * @FLOW3\SkipCsrfProtection */ public function indexAction(array $module) { $moduleRequest = new ActionRequest($this->request); $moduleRequest->setArgumentNamespace('moduleArguments'); $moduleRequest->setControllerObjectName($module['controller']); $moduleRequest->setControllerActionName($module['action']); if ($this->request->hasArgument($moduleRequest->getArgumentNamespace()) === TRUE && is_array($this->request->getArgument($moduleRequest->getArgumentNamespace()))) { $moduleRequest->setArguments($this->request->getArgument($moduleRequest->getArgumentNamespace())); } foreach ($this->request->getPluginArguments() as $argumentNamespace => $argument) { $moduleRequest->setArgument('--' . $argumentNamespace, $argument); } $modules = explode('/', $module['module']); $moduleConfiguration = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $modules)); $moduleConfiguration['path'] = $module['module']; $moduleBreadcrumb = array(); $path = array(); foreach ($modules as $moduleIdentifier) { array_push($path, $moduleIdentifier); $config = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($this->settings['modules'], implode('.submodules.', $path)); $moduleBreadcrumb[implode('/', $path)] = $config['label']; } $moduleRequest->setArgument('__moduleConfiguration', $moduleConfiguration); $moduleRequest->setArgument('__moduleBreadcrumb', $moduleBreadcrumb); $moduleResponse = new Response($this->response); $this->dispatcher->dispatch($moduleRequest, $moduleResponse); $this->view->assignMultiple(array('moduleClass' => implode('-', $modules), 'moduleContents' => $moduleResponse->getContent(), 'title' => $moduleRequest->hasArgument('title') ? $moduleRequest->getArgument('title') : $moduleConfiguration['label'], 'rootModule' => array_shift($modules), 'submodule' => array_shift($modules), 'moduleConfiguration' => $moduleConfiguration)); }
/** * Iterate through the configured modules, find the matching module and set * the route path accordingly * * @param array $value (contains action, controller and package of the module controller) * @return boolean */ protected function resolveValue($value) { if (is_array($value)) { $this->value = isset($value['@action']) && $value['@action'] !== 'index' ? $value['@action'] : ''; $exceedingArguments = array(); foreach ($value as $argumentKey => $argumentValue) { if (substr($argumentKey, 0, 1) !== '@' && substr($argumentKey, 0, 2) !== '__') { $exceedingArguments[$argumentKey] = $argumentValue; } } if ($exceedingArguments !== array()) { $exceedingArguments = \TYPO3\FLOW3\Utility\Arrays::removeEmptyElementsRecursively($exceedingArguments); $exceedingArguments = $this->persistenceManager->convertObjectsToIdentityArrays($exceedingArguments); $queryString = http_build_query(array($this->name => $exceedingArguments), NULL, '&'); if ($queryString !== '') { $this->value .= '?' . $queryString; } } } return TRUE; }
/** * Returns a fresh or existing instance of the object specified by $objectName. * * This specialized get() method is able to do setter injection for properties * defined in the object configuration of the specified object. * * @param string $objectName The name of the object to return an instance of * @return object The object instance * @throws \TYPO3\FLOW3\Object\Exception\CannotBuildObjectException * @throws \TYPO3\FLOW3\Object\Exception\UnresolvedDependenciesException * @throws \TYPO3\FLOW3\Object\Exception\UnknownObjectException */ public function get($objectName) { if (isset($this->objects[$objectName]['i'])) { return $this->objects[$objectName]['i']; } if (isset($this->objectConfigurations[$objectName]) && count($this->objectConfigurations[$objectName]->getArguments()) > 0) { throw new Exception\CannotBuildObjectException('Cannot build object "' . $objectName . '" because constructor injection is not available in the compile time Object Manager. Refactor your code to use setter injection instead. Configuration source: ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . '. Build stack: ' . implode(', ', $this->objectNameBuildStack), 1297090026); } if (!isset($this->objects[$objectName])) { throw new Exception\UnknownObjectException('Cannot build object "' . $objectName . '" because it is unknown to the compile time Object Manager.', 1301477694); } if ($this->objects[$objectName]['s'] !== Configuration::SCOPE_SINGLETON) { throw new Exception\CannotBuildObjectException('Cannot build object "' . $objectName . '" because the get() method in the compile time Object Manager only supports singletons.', 1297090027); } $this->objectNameBuildStack[] = $objectName; $object = parent::get($objectName); foreach ($this->objectConfigurations[$objectName]->getProperties() as $propertyName => $property) { if ($property->getAutowiring() !== Configuration::AUTOWIRING_MODE_ON) { continue; } switch ($property->getType()) { case Property::PROPERTY_TYPES_STRAIGHTVALUE: $value = $property->getValue(); break; case Property::PROPERTY_TYPES_SETTING: $value = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($this->allSettings, explode('.', $property->getValue())); break; case Property::PROPERTY_TYPES_OBJECT: $propertyObjectName = $property->getValue(); if (!is_string($propertyObjectName)) { throw new Exception\CannotBuildObjectException('The object definition of "' . $objectName . '::' . $propertyName . '" is too complex for the compile time Object Manager. You can only use plain object names, not factories and the like. Check configuration in ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . ' and objects which depend on ' . $objectName . '.', 1297099659); } $value = $this->get($propertyObjectName); break; default: throw new Exception\CannotBuildObjectException('Invalid property type.', 1297090029); break; } if (method_exists($object, $setterMethodName = 'inject' . ucfirst($propertyName))) { $object->{$setterMethodName}($value); } elseif (method_exists($object, $setterMethodName = 'set' . ucfirst($propertyName))) { $object->{$setterMethodName}($value); } else { throw new Exception\UnresolvedDependenciesException('Could not inject configured property "' . $propertyName . '" into "' . $objectName . '" because no injection method exists, but for compile time use this is required. Configuration source: ' . $this->objectConfigurations[$objectName]->getConfigurationSourceHint() . '.', 1297110953); } } $initializationLifecycleMethodName = $this->objectConfigurations[$objectName]->getLifecycleInitializationMethodName(); if (method_exists($object, $initializationLifecycleMethodName)) { $object->{$initializationLifecycleMethodName}(); } $shutdownLifecycleMethodName = $this->objectConfigurations[$objectName]->getLifecycleShutdownMethodName(); if (method_exists($object, $shutdownLifecycleMethodName)) { $this->shutdownObjects[$object] = $shutdownLifecycleMethodName; } array_pop($this->objectNameBuildStack); return $object; }
/** * @dataProvider arrayMergeRecursiveOverruleData * @test */ public function arrayMergeRecursiveOverruleMergesSimpleArrays($inputArray1, $inputArray2, $dontAddNewKeys, $emptyValuesOverride, $expected) { $actual = \TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($inputArray1, $inputArray2, $dontAddNewKeys, $emptyValuesOverride); $this->assertSame($expected, $actual); }
/** * 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) { if ($this->context->isDevelopment()) { $useIgBinary = extension_loaded('igbinary'); foreach ($this->packageManager->getActivePackages() as $packageKey => $package) { if ($this->packageManager->isPackageFrozen($packageKey)) { $pathAndFilename = $this->getPrecompiledReflectionStoragePath() . $packageKey . '.dat'; if (file_exists($pathAndFilename)) { $data = $useIgBinary ? igbinary_unserialize(file_get_contents($pathAndFilename)) : unserialize(file_get_contents($pathAndFilename)); foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = \TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($this->{$propertyName}, $propertyValue); } } } } } return FALSE; } foreach ($data as $propertyName => $propertyValue) { $this->{$propertyName} = $propertyValue; } return TRUE; }
/** * FIXME: Not yet completely refactored to new proxy mechanism * * @param array $argumentConfigurations * @return string */ protected function buildMethodParametersCode(array $argumentConfigurations) { $preparedArguments = array(); foreach ($argumentConfigurations as $argument) { if ($argument === NULL) { $preparedArguments[] = 'NULL'; } else { $argumentValue = $argument->getValue(); switch ($argument->getType()) { case \TYPO3\FLOW3\Object\Configuration\ConfigurationArgument::ARGUMENT_TYPES_OBJECT: if ($argumentValue instanceof \TYPO3\FLOW3\Object\Configuration\Configuration) { $argumentValueObjectName = $argumentValue->getObjectName(); if ($this->objectConfigurations[$argumentValueObjectName]->getScope() === \TYPO3\FLOW3\Object\Configuration\Configuration::SCOPE_PROTOTYPE) { $preparedArguments[] = '$this->getPrototype(\'' . $argumentValueObjectName . '\', array(' . $this->buildMethodParametersCode($argumentValue->getArguments(), $this->objectConfigurations) . '))'; } else { $preparedArguments[] = '\\TYPO3\\FLOW3\\Core\\Bootstrap::$staticObjectManager->get(\'' . $argumentValueObjectName . '\')'; } } else { if (strpos($argumentValue, '.') !== FALSE) { $settingPath = explode('.', $argumentValue); $settings = Arrays::getValueByPath($this->configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS), array_shift($settingPath)); $argumentValue = Arrays::getValueByPath($settings, $settingPath); } $preparedArguments[] = '\\TYPO3\\FLOW3\\Core\\Bootstrap::$staticObjectManager->get(\'' . $argumentValue . '\')'; } break; case \TYPO3\FLOW3\Object\Configuration\ConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE: $preparedArguments[] = var_export($argumentValue, TRUE); break; case \TYPO3\FLOW3\Object\Configuration\ConfigurationArgument::ARGUMENT_TYPES_SETTING: $preparedArguments[] = '\\TYPO3\\FLOW3\\Core\\Bootstrap::$staticObjectManager->getSettingsByPath(explode(\'.\', \'' . $argumentValue . '\'))'; break; } } } return implode(', ', $preparedArguments); }
/** * Returns all parent roles for the given role, that are configured in the policy. * * @param \TYPO3\FLOW3\Security\Policy\Role $role The role to get the parents for * @return array<TYPO3\Security\Policy\Role> Array of parent roles */ public function getAllParentRoles(\TYPO3\FLOW3\Security\Policy\Role $role) { $result = array(); $parentRoles = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($this->policy, 'roles.' . $role); if (is_array($parentRoles)) { foreach ($this->policy['roles'][(string) $role] as $currentIdentifier) { $currentParent = new \TYPO3\FLOW3\Security\Policy\Role($currentIdentifier); if (!in_array($currentParent, $result)) { $result[] = $currentParent; } foreach ($this->getAllParentRoles($currentParent) as $currentGrandParent) { if (!in_array($currentGrandParent, $result)) { $result[] = $currentGrandParent; } } } } return $result; }
/** * Routes the specified web request by setting the controller name, action and possible * parameters. If the request could not be routed, it will be left untouched. * * @param \TYPO3\FLOW3\Http\Request $httpRequest The web request to be analyzed. Will be modified by the router. * @return \TYPO3\FLOW3\Mvc\ActionRequest */ public function route(\TYPO3\FLOW3\Http\Request $httpRequest) { $this->actionRequest = $httpRequest->createActionRequest(); $routePath = substr($httpRequest->getUri()->getPath(), strlen($httpRequest->getBaseUri()->getPath())); $matchResults = $this->findMatchResults($routePath); if ($matchResults !== NULL) { $requestArguments = $this->actionRequest->getArguments(); $mergedArguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $matchResults); $this->actionRequest->setArguments($mergedArguments); } $this->setDefaultControllerAndActionNameIfNoneSpecified(); return $this->actionRequest; }
/** * Parses a RFC 2616 Media Type and returns its parts in an associative array. * * media-type = type "/" subtype *( ";" parameter) * * The media type "text/html; charset=UTF-8" would be parsed and returned with * the following array keys and values: * * "type" => the type as a string, "text" * "subtype" => the subtype as a string, "html" * "parameters" => an array of parameter names and values, array("charset" => "UTF-8") * * @param string $rawMediaType The raw media type, for example "application/json; charset=UTF-8" * @return array An associative array with parsed information */ public static function parseMediaType($rawMediaType) { preg_match(self::PATTERN_SPLITMEDIATYPE, $rawMediaType, $matches); $result = array(); $result['type'] = isset($matches['type']) ? $matches['type'] : ''; $result['subtype'] = isset($matches['subtype']) ? $matches['subtype'] : ''; $result['parameters'] = array(); if (isset($matches['parameters'])) { foreach (Arrays::trimExplode(';', $matches['parameters']) as $parameter) { $pieces = explode('=', $parameter); if (count($pieces) === 2) { $name = trim($pieces[0]); $result['parameters'][$name] = trim($pieces[1]); } } } return $result; }
/** * Checks whether $routeValues can be resolved to a corresponding uri. * If all Route Parts can resolve one or more of the $routeValues, TRUE is * returned and $this->matchingURI contains the generated URI (excluding * protocol and host). * * @param array $routeValues An array containing key/value pairs to be resolved to uri segments * @return boolean TRUE if this Route corresponds to the given $routeValues, otherwise FALSE * @throws \TYPO3\FLOW3\Mvc\Exception\InvalidRoutePartValueException * @see getMatchingUri() */ public function resolves(array $routeValues) { $this->matchingUri = NULL; if ($this->uriPattern === NULL) { return FALSE; } if (!$this->isParsed) { $this->parse(); } $matchingUri = ''; $mergedRouteValues = \TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($this->defaults, $routeValues); $requireOptionalRouteParts = FALSE; $matchingOptionalUriPortion = ''; foreach ($this->routeParts as $routePart) { if (!$routePart->resolve($routeValues)) { if (!$routePart->hasDefaultValue()) { return FALSE; } } $routePartValue = NULL; if ($routePart->hasValue()) { $routePartValue = $routePart->getValue(); if (!is_string($routePartValue)) { throw new \TYPO3\FLOW3\Mvc\Exception\InvalidRoutePartValueException('RoutePart::getValue() must return a string after calling RoutePart::resolve(), got ' . (is_object($routePartValue) ? get_class($routePartValue) : gettype($routePartValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } } $routePartDefaultValue = $routePart->getDefaultValue(); if ($routePartDefaultValue !== NULL && !is_string($routePartDefaultValue)) { throw new \TYPO3\FLOW3\Mvc\Exception\InvalidRoutePartValueException('RoutePart::getDefaultValue() must return a string, got ' . (is_object($routePartDefaultValue) ? get_class($routePartDefaultValue) : gettype($routePartDefaultValue)) . ' for RoutePart "' . get_class($routePart) . '" in Route "' . $this->getName() . '".'); } if (!$routePart->isOptional()) { $matchingUri .= $routePart->hasValue() ? $routePartValue : $routePartDefaultValue; $requireOptionalRouteParts = FALSE; continue; } if ($routePart->hasValue() && $routePartValue !== $routePartDefaultValue) { $matchingOptionalUriPortion .= $routePartValue; $requireOptionalRouteParts = TRUE; } else { $matchingOptionalUriPortion .= $routePartDefaultValue; } if ($requireOptionalRouteParts) { $matchingUri .= $matchingOptionalUriPortion; $matchingOptionalUriPortion = ''; } } if ($this->compareAndRemoveMatchingDefaultValues($this->defaults, $routeValues) !== TRUE) { return FALSE; } if (isset($routeValues['@format']) && $routeValues['@format'] === '') { unset($routeValues['@format']); } $this->throwExceptionIfTargetControllerDoesNotExist($mergedRouteValues); // add query string if (count($routeValues) > 0) { $routeValues = \TYPO3\FLOW3\Utility\Arrays::removeEmptyElementsRecursively($routeValues); $routeValues = $this->persistenceManager->convertObjectsToIdentityArrays($routeValues); if (!$this->appendExceedingArguments) { $internalArguments = $this->extractInternalArguments($routeValues); if ($routeValues !== array()) { return FALSE; } $routeValues = $internalArguments; } $queryString = http_build_query($routeValues, NULL, '&'); if ($queryString !== '') { $matchingUri .= strpos($matchingUri, '?') !== FALSE ? '&' . $queryString : '?' . $queryString; } } $this->matchingUri = $matchingUri; return TRUE; }
/** * 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 FLOW3's form and validation mechanisms. * * @return \TYPO3\FLOW3\Mvc\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 = $this->getHttpRequest()->createActionRequest(); $arguments = array(); if (isset($referrerArray['arguments'])) { $serializedArgumentsWithHmac = $referrerArray['arguments']; $serializedArguments = $this->hashService->validateAndStripHmac($serializedArgumentsWithHmac); $arguments = unserialize(base64_decode($serializedArguments)); unset($referrerArray['arguments']); } $referringRequest->setArguments(\TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($arguments, $referrerArray)); return $referringRequest; } else { $this->referringRequest = $this->internalArguments['__referrer']; } return $this->referringRequest; }
/** * Invokes the Factory defined in the object configuration of the specified object in order * to build an instance. Arguments which were defined in the object configuration are * passed to the factory method. * * @param string $objectName Name of the object to build * @return object The built object */ protected function buildObjectByFactory($objectName) { $factory = $this->get($this->objects[$objectName]['f'][0]); $factoryMethodName = $this->objects[$objectName]['f'][1]; $factoryMethodArguments = array(); foreach ($this->objects[$objectName]['fa'] as $index => $argumentInformation) { switch ($argumentInformation['t']) { case ObjectConfigurationArgument::ARGUMENT_TYPES_SETTING: $settingPath = explode('.', $argumentInformation['v']); $factoryMethodArguments[$index] = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($this->allSettings, $settingPath); break; case ObjectConfigurationArgument::ARGUMENT_TYPES_STRAIGHTVALUE: $factoryMethodArguments[$index] = $argumentInformation['v']; break; case ObjectConfigurationArgument::ARGUMENT_TYPES_OBJECT: $factoryMethodArguments[$index] = $this->get($argumentInformation['v']); break; } } if (count($factoryMethodArguments) === 0) { return $factory->{$factoryMethodName}(); } else { return call_user_func_array(array($factory, $factoryMethodName), $factoryMethodArguments); } }
/** * Process MongoDB results, add metadata and process object * values by loading objects. This method processes documents * batched for loading nested entities. * * @param array $documents Documents as objects * @param array &$knownObjects * @return array * @author Christopher Hlubek <*****@*****.**> */ protected function documentsToObjectData(array $documents, array &$knownObjects = array()) { $identifiersToFetch = array(); $data = array(); foreach ($documents as $document) { $objectData = \TYPO3\FLOW3\Utility\Arrays::convertObjectToArray($document); $objectData['identifier'] = $objectData['_id']; unset($objectData['_id']); $knownObjects[$objectData['identifier']] = TRUE; if (!isset($objectData['classname'])) { throw new \TYPO3\MongoDB\InvalidResultException('Expected property "classname" in document', 1310221818, NULL, $document); } if (!isset($this->classSchemata[$objectData['classname']])) { throw new \TYPO3\MongoDB\InvalidResultException('Class "' . $objectData['classname'] . '" was not registered', 1310221905, NULL, $document); } $this->processResultProperties($objectData['properties'], $identifiersToFetch, $knownObjects, $this->classSchemata[$objectData['classname']]); $data[] = $objectData; } if (count($identifiersToFetch) > 0) { // TODO Implement eager loading of additional documents $documents = array(); $fetchedObjectsData = $this->documentsToObjectData($documents, $knownObjects); foreach ($fetchedObjectsData as $fetchedObjectData) { $identifiersToFetch[$fetchedObjectData['identifier']] = $fetchedObjectData; } } return $data; }
/** * Imports fjson files into TYPO3CR nodes. * See Settings.yaml for an exemplary configuration for the documentation bundles * * @param string $bundle bundle to import. If not specified all configured bundles will be imported * @return void */ public function importCommand($bundle = NULL) { $bundles = $bundle !== NULL ? array($bundle) : array_keys($this->settings['bundles']); $defaultConfiguration = isset($this->settings['defaultConfiguration']) ? $this->settings['defaultConfiguration'] : array(); foreach ($bundles as $bundle) { if (!isset($this->settings['bundles'][$bundle])) { $this->outputLine('Bundle "%s" is not configured', array($bundle)); $this->quit(1); } $this->bundleConfiguration = \TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($defaultConfiguration, $this->settings['bundles'][$bundle]); $this->importBundle($bundle); $this->outputLine('---'); } $this->outputLine('Done'); }
/** * Checks whether $routeValues contains elements which correspond to this Dynamic Route Part. * If a corresponding element is found in $routeValues, this element is removed from the array. * * @param array $routeValues An array with key/value pairs to be resolved by Dynamic Route Parts. * @return boolean TRUE if current Route Part could be resolved, otherwise FALSE */ public final function resolve(array &$routeValues) { $this->value = NULL; if ($this->name === NULL || $this->name === '') { return FALSE; } $valueToResolve = $this->findValueToResolve($routeValues); if (!$this->resolveValue($valueToResolve)) { return FALSE; } if ($this->lowerCase) { $this->value = strtolower($this->value); } $routeValues = \TYPO3\FLOW3\Utility\Arrays::unsetValueByPath($routeValues, $this->name); return TRUE; }
/** * Merges specified arguments with arguments from request. * * If $this->request is no sub request, request arguments will only be merged if $this->addQueryString is set. * Otherwise all request arguments except for the ones prefixed with the current request argument namespace will * be merged. Additionally special arguments (PackageKey, SubpackageKey, ControllerName & Action) are merged. * * The argument provided through the $arguments parameter always overrule the request * arguments. * * The request hierarchy is structured as follows: * root (HTTP) > main (Action) > sub (Action) > sub sub (Action) * * @param array $arguments * @return void */ protected function mergeArgumentsWithRequestArguments(array &$arguments) { $requestArguments = array(); $mainRequest = $this->request->getMainRequest(); $isSubRequest = $this->request !== $mainRequest; if ($isSubRequest) { $requestArguments = $mainRequest->getArguments(); // remove all arguments of the current sub request if ($this->request->getArgumentNamespace() !== '') { $requestNamespace = $this->getRequestNamespacePath($this->request); if ($this->addQueryString === FALSE) { $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace); } else { foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) { $requestArguments = Arrays::unsetValueByPath($requestArguments, $requestNamespace . '.' . $argumentToBeExcluded); } } } // merge special arguments (package, subpackage, controller & action) from main request $mainRequestPackageKey = $mainRequest->getControllerPackageKey(); if (!empty($mainRequestPackageKey)) { $requestArguments['@package'] = $mainRequestPackageKey; } $mainRequestSubpackageKey = $mainRequest->getControllerSubpackageKey(); if (!empty($mainRequestSubpackageKey)) { $requestArguments['@subpackage'] = $mainRequestSubpackageKey; } $mainRequestControllerName = $mainRequest->getControllerName(); if (!empty($mainRequestControllerName)) { $requestArguments['@controller'] = $mainRequestControllerName; } $mainRequestActionName = $mainRequest->getControllerActionName(); if (!empty($mainRequestActionName)) { $requestArguments['@action'] = $mainRequestActionName; } } elseif ($this->addQueryString === TRUE) { $requestArguments = $this->request->getArguments(); foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) { unset($requestArguments[$argumentToBeExcluded]); } } if (count($requestArguments) === 0) { return; } $arguments = Arrays::arrayMergeRecursiveOverrule($requestArguments, $arguments); }
/** * Generate a schema for the given configuration or YAML file. * * ./flow3 configuration:generateschema --type Settings --path TYPO3.FLOW3.persistence * * The schema will be output to standard output. * * @param string $type Configuration type to create a schema for * @param string $path path to the subconfiguration separated by "." like "TYPO3.FLOW3" * @param string $yaml YAML file to create a schema for * @return void */ public function generateSchemaCommand($type = NULL, $path = NULL, $yaml = NULL) { $data = NULL; if ($yaml !== NULL && is_file($yaml) && is_readable($yaml)) { $data = \Symfony\Component\Yaml\Yaml::parse($yaml); } elseif ($type !== NULL) { $data = $this->configurationManager->getConfiguration($type); if ($path !== NULL) { $data = \TYPO3\FLOW3\Utility\Arrays::getValueByPath($data, $path); } } if (empty($data)) { $this->outputLine('Data was not found or is empty'); return; } $yaml = \Symfony\Component\Yaml\Yaml::dump($this->schemaGenerator->generate($data), 99); $this->output($yaml . chr(10)); }
/** * Merges all routes in $routesConfiguration with the sub routes in $subRoutesConfiguration * * @param array $routesConfiguration * @param array $subRoutesConfiguration * @param string $subRouteKey the key of the sub route: <subRouteKey> * @return array the merged route configuration * @throws \TYPO3\FLOW3\Configuration\Exception\ParseErrorException */ protected function buildSubrouteConfigurations(array $routesConfiguration, array $subRoutesConfiguration, $subRouteKey) { $mergedSubRoutesConfigurations = array(); foreach ($subRoutesConfiguration as $subRouteConfiguration) { foreach ($routesConfiguration as $routeConfiguration) { $subRouteConfiguration['name'] = sprintf('%s :: %s', isset($routeConfiguration['name']) ? $routeConfiguration['name'] : 'Unnamed Route', isset($subRouteConfiguration['name']) ? $subRouteConfiguration['name'] : 'Unnamed Subroute'); if (!isset($subRouteConfiguration['uriPattern'])) { throw new \TYPO3\FLOW3\Configuration\Exception\ParseErrorException('No uriPattern defined in route configuration "' . $subRouteConfiguration['name'] . '".', 1274197615); } $subRouteConfiguration['uriPattern'] = str_replace('<' . $subRouteKey . '>', $subRouteConfiguration['uriPattern'], $routeConfiguration['uriPattern']); $subRouteConfiguration = Arrays::arrayMergeRecursiveOverrule($routeConfiguration, $subRouteConfiguration); unset($subRouteConfiguration['subRoutes']); $mergedSubRoutesConfigurations[] = $subRouteConfiguration; } } return $mergedSubRoutesConfigurations; }