2 declare(strict_types = 1);
50 $this->routesOfPlugin = $this->configuration[
'routes'] ?? [];
53 if (isset($this->configuration[
'extension']) && isset($this->configuration[
'plugin'])) {
54 $extensionName = $this->configuration[
'extension'];
55 $pluginName = $this->configuration[
'plugin'];
56 $extensionName = str_replace(
' ',
'', ucwords(str_replace(
'_',
' ', $extensionName)));
57 $pluginSignature = strtolower($extensionName .
'_' . $pluginName);
58 $this->
namespace = 'tx_' . $pluginSignature;
70 $defaultPageRoute = $collection->get(
'default');
73 $collection->add($this->
namespace .
'_' . $i++, $route);
89 $options = array_merge($defaultPageRoute->getOptions(), [
'_enhancer' => $this,
'utf8' =>
true,
'_arguments' => $arguments]);
90 $route =
new Route(rtrim($defaultPageRoute->getPath(),
'/') .
'/' . ltrim($routePath,
'/'), [], [], $options);
92 $defaults = array_merge_recursive(
93 $defaultPageRoute->getDefaults(),
102 $defaults = array_merge_recursive(
106 $route->setDefaults($defaults);
108 $this->
applyRequirements($route, $this->configuration[
'requirements'] ?? [], $this->
namespace);
117 if (!is_array($originalParameters[$this->
namespace] ??
null)) {
122 && !empty($this->configuration[
'defaultController'])
125 $this->configuration[
'defaultController'],
126 $originalParameters[$this->
namespace],
133 $defaultPageRoute = $collection->get(
'default');
140 $parameters = $originalParameters;
141 unset($parameters[$this->
namespace][
'action']);
142 unset($parameters[$this->
namespace][
'controller']);
143 $compiledRoute = $variant->compile();
146 $variables = array_flip($compiledRoute->getPathVariables());
147 $mergedParams = array_replace($variant->getDefaults(), $deflatedParameters);
151 if (array_diff_key($variables, $mergedParams)) {
154 $variant->addOptions([
'deflatedParameters' => $deflatedParameters]);
155 $collection->add($this->
namespace .
'_' . $i++, $variant);
174 if (empty($internals[
'_controller'] ??
null)) {
178 $internals[
'_controller'],
179 $parameters[$this->
namespace],
194 if (!is_array($parameters[$this->
namespace])) {
197 if (!$route->hasDefault(
'_controller')) {
200 $controller = $route->getDefault(
'_controller');
201 list($controllerName, $actionName) = explode(
'::', $controller);
202 if ($controllerName !== $parameters[$this->
namespace][
'controller']) {
205 if ($actionName !== $parameters[$this->
namespace][
'action']) {
218 return !empty($target[
'controller']) && !empty($target[
'action']);
230 if (strpos($controllerActionValue,
'::') ===
false) {
233 list($controllerName, $actionName) = explode(
'::', $controllerActionValue, 2);
235 if ($tryUpdate && empty($target[
'action']) && $controllerName === ($target[
'controller'] ??
null)) {
236 $target[
'action'] = $actionName;
238 } elseif ($tryUpdate && empty($target[
'controller']) && !empty($target[
'action'])) {
239 $target[
'controller'] = $controllerName;
242 $target[
'controller'] = $controllerName;
243 $target[
'action'] = $actionName;