2 namespace TYPO3\CMS\Extbase\Mvc\Web;
126 if (empty($configuration[
'extensionName'])) {
127 throw new MvcException(
'"extensionName" is not properly configured. Request can\'t be dispatched!', 1289843275);
129 if (empty($configuration[
'pluginName'])) {
130 throw new MvcException(
'"pluginName" is not properly configured. Request can\'t be dispatched!', 1289843277);
132 if (!empty($configuration[
'vendorName'])) {
133 $this->vendorName = $configuration[
'vendorName'];
135 $this->vendorName = null;
137 $this->extensionName = $configuration[
'extensionName'];
138 $this->pluginName = $configuration[
'pluginName'];
139 $this->defaultControllerName = current(array_keys($configuration[
'controllerConfiguration']));
140 $this->allowedControllerActions = array();
141 foreach ($configuration[
'controllerConfiguration'] as $controllerName => $controllerActions) {
142 $this->allowedControllerActions[$controllerName] = $controllerActions[
'actions'];
144 if (!empty($configuration[
'format'])) {
145 $this->defaultFormat = $configuration[
'format'];
154 public function build()
157 $pluginNamespace = $this->extensionService->getPluginNamespace($this->extensionName, $this->pluginName);
158 $parameters = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($pluginNamespace);
160 if (isset($files[$pluginNamespace]) && is_array($files[$pluginNamespace])) {
161 $parameters = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($parameters, $files[$pluginNamespace]);
166 $request = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
167 if ($this->vendorName !== null) {
168 $request->setControllerVendorName($this->vendorName);
170 $request->setPluginName($this->pluginName);
171 $request->setControllerExtensionName($this->extensionName);
172 $request->setControllerName($controllerName);
173 $request->setControllerActionName($actionName);
176 $request->setMethod($this->environmentService->getServerRequestMethod());
177 if (is_string($parameters[
'format']) && $parameters[
'format'] !==
'') {
178 $request->setFormat(filter_var($parameters[
'format'], FILTER_SANITIZE_STRING));
180 $request->setFormat($this->defaultFormat);
182 foreach ($parameters as $argumentName => $argumentValue) {
183 $request->setArgument($argumentName, $argumentValue);
201 if (!isset($parameters[
'controller']) || $parameters[
'controller'] ===
'') {
202 if ($this->defaultControllerName ===
'') {
203 throw new MvcException(
'The default controller for extension "' . $this->extensionName .
'" and plugin "' . $this->pluginName .
'" can not be determined. Please check for TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php.', 1316104317);
207 $allowedControllerNames = array_keys($this->allowedControllerActions);
208 if (!in_array($parameters[
'controller'], $allowedControllerNames)) {
210 if (isset($configuration[
'mvc'][
'throwPageNotFoundExceptionIfActionCantBeResolved']) && (
bool)$configuration[
'mvc'][
'throwPageNotFoundExceptionIfActionCantBeResolved']) {
211 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException(
'The requested resource was not found', 1313857897);
212 }
elseif (isset($configuration[
'mvc'][
'callDefaultActionIfActionCantBeResolved']) && (
bool)$configuration[
'mvc'][
'callDefaultActionIfActionCantBeResolved']) {
215 throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException(
'The controller "' . $parameters[
'controller'] .
'" is not allowed by this plugin. Please check for TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php.', 1313855173);
217 return filter_var($parameters[
'controller'], FILTER_SANITIZE_STRING);
234 $defaultActionName = is_array($this->allowedControllerActions[$controllerName]) ? current($this->allowedControllerActions[$controllerName]) :
'';
235 if (!isset($parameters[
'action']) || $parameters[
'action'] ===
'') {
236 if ($defaultActionName ===
'') {
237 throw new MvcException(
'The default action can not be determined for controller "' . $controllerName .
'". Please check TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php.', 1295479651);
239 return $defaultActionName;
241 $actionName = $parameters[
'action'];
242 $allowedActionNames = $this->allowedControllerActions[$controllerName];
243 if (!in_array($actionName, $allowedActionNames)) {
245 if (isset($configuration[
'mvc'][
'throwPageNotFoundExceptionIfActionCantBeResolved']) && (
bool)$configuration[
'mvc'][
'throwPageNotFoundExceptionIfActionCantBeResolved']) {
246 throw new \TYPO3\CMS\Core\Error\Http\PageNotFoundException(
'The requested resource was not found', 1313857898);
247 }
elseif (isset($configuration[
'mvc'][
'callDefaultActionIfActionCantBeResolved']) && (
bool)$configuration[
'mvc'][
'callDefaultActionIfActionCantBeResolved']) {
248 return $defaultActionName;
250 throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidActionNameException(
'The action "' . $actionName .
'" (controller "' . $controllerName .
'") is not allowed by this plugin. Please check TYPO3\\CMS\\Extbase\\Utility\\ExtensionUtility::configurePlugin() in your ext_localconf.php.', 1313855175);
252 return filter_var($actionName, FILTER_SANITIZE_STRING);
264 $untangledFiles = array();
265 $fieldPaths = array();
266 foreach ($convolutedFiles as $firstLevelFieldName => $fieldInformation) {
267 if (!is_array($fieldInformation[
'error'])) {
268 $fieldPaths[] = array($firstLevelFieldName);
270 $newFieldPaths = $this->
calculateFieldPaths($fieldInformation[
'error'], $firstLevelFieldName);
271 array_walk($newFieldPaths,
function (&$value, $key) {
272 $value = explode(
'/', $value);
274 $fieldPaths = array_merge($fieldPaths, $newFieldPaths);
277 foreach ($fieldPaths as $fieldPath) {
278 if (count($fieldPath) === 1) {
279 $fileInformation = $convolutedFiles[$fieldPath[0]];
281 $fileInformation = array();
282 foreach ($convolutedFiles[$fieldPath[0]] as $key => $subStructure) {
283 $fileInformation[$key] = \TYPO3\CMS\Extbase\Utility\ArrayUtility::getValueByPath($subStructure, array_slice($fieldPath, 1));
286 $untangledFiles = \TYPO3\CMS\Extbase\Utility\ArrayUtility::setValueByPath($untangledFiles, $fieldPath, $fileInformation);
288 return $untangledFiles;
300 $fieldPaths = array();
301 if (is_array($structure)) {
302 foreach ($structure as $key => $subStructure) {
303 $fieldPath = ($firstLevelFieldName !== null ? $firstLevelFieldName .
'/' :
'') . $key;
304 if (is_array($subStructure)) {
306 $fieldPaths[] = $fieldPath .
'/' . $subFieldPath;
309 $fieldPaths[] = $fieldPath;