/** * This removes controller and/or action arguments from given controllerArguments * if they are equal to the default controller/action of the target plugin. * Note: This is only active in FE mode and if feature "skipDefaultArguments" is enabled * * @see \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::isFeatureEnabled() * @param array $controllerArguments the current controller arguments to be modified * @param string $extensionName target extension name * @param string $pluginName target plugin name * @return array */ protected function removeDefaultControllerAndAction(array $controllerArguments, $extensionName, $pluginName) { $defaultControllerName = $this->extensionService->getDefaultControllerNameByPlugin($extensionName, $pluginName); if (isset($controllerArguments['action'])) { $defaultActionName = $this->extensionService->getDefaultActionNameByPluginAndController($extensionName, $pluginName, $controllerArguments['controller']); if ($controllerArguments['action'] === $defaultActionName) { unset($controllerArguments['action']); } } if ($controllerArguments['controller'] === $defaultControllerName) { unset($controllerArguments['controller']); } return $controllerArguments; }
/** * @test */ public function getDefaultActionNameByPluginAndControllerReturnsFirstActionNameOfGivenController() { $expectedResult = 'someAction'; $actualResult = $this->extensionService->getDefaultActionNameByPluginAndController('SomeOtherExtensionName', 'SecondPlugin', 'SecondControllerName'); $this->assertEquals($expectedResult, $actualResult); }