/** * @test */ public function getPluginNameByActionReturnsCurrentIfItCanHandleTheActionEvenIfMoreThanOnePluginMatches() { $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface'); $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK)->will($this->returnValue(array('extensionName' => 'CurrentExtension', 'pluginName' => 'CurrentPlugin', 'controllerConfiguration' => array('ControllerName' => array('actions' => array('otherAction')))))); $mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManager'); $mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_Configuration_ConfigurationManagerInterface')->will($this->returnValue($mockConfigurationManager)); t3lib_div::setSingletonInstance('Tx_Extbase_Object_ObjectManager', $mockObjectManager); $actualResult = Tx_Extbase_Utility_Extension::getPluginNameByAction('CurrentExtension', 'ControllerName', 'otherAction'); $expectedResult = 'CurrentPlugin'; $this->assertEquals($expectedResult, $actualResult); }
/** * Creates an URI used for linking to an Extbase action. * Works in Frontend and Backend mode of TYPO3. * * @param string $actionName Name of the action to be called * @param array $controllerArguments Additional query parameters. Will be "namespaced" and merged with $this->arguments. * @param string $controllerName Name of the target controller. If not set, current ControllerName is used. * @param string $extensionName Name of the target extension, without underscores. If not set, current ExtensionName is used. * @param string $pluginName Name of the target plugin. If not set, current PluginName is used. * @return string the rendered URI * @api * @see build() */ public function uriFor($actionName = NULL, $controllerArguments = array(), $controllerName = NULL, $extensionName = NULL, $pluginName = NULL) { if ($actionName !== NULL) { $controllerArguments['action'] = $actionName; } if ($controllerName !== NULL) { $controllerArguments['controller'] = $controllerName; } else { $controllerArguments['controller'] = $this->request->getControllerName(); } if ($extensionName === NULL) { $extensionName = $this->request->getControllerExtensionName(); } if ($pluginName === NULL && TYPO3_MODE === 'FE') { $pluginName = Tx_Extbase_Utility_Extension::getPluginNameByAction($extensionName, $controllerArguments['controller'], $controllerArguments['action']); } if ($pluginName === NULL) { $pluginName = $this->request->getPluginName(); } if ($this->targetPageUid === NULL && TYPO3_MODE === 'FE') { $this->targetPageUid = Tx_Extbase_Utility_Extension::getTargetPidByPlugin($extensionName, $pluginName); } if ($this->format !== '') { $controllerArguments['format'] = $this->format; } if ($this->argumentPrefix !== NULL) { $prefixedControllerArguments = array($this->argumentPrefix => $controllerArguments); } else { $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName); $prefixedControllerArguments = array($pluginNamespace => $controllerArguments); } $this->arguments = t3lib_div::array_merge_recursive_overrule($this->arguments, $prefixedControllerArguments); if ($actionName !== NULL && $this->useCacheHash === TRUE && !Tx_Extbase_Utility_Extension::isActionCacheable($extensionName, $pluginName, $controllerArguments['controller'], $actionName)) { $this->setUseCacheHash(FALSE); } return $this->build(); }
/** * Resolve a plugin name for this Model Object * * @param mixed $object Instance or classname of Model object * @return string * @api */ public function getPluginName($object) { $extensionName = $this->getExtensionName($object); $controllerName = $this->getControllerName($object); if (class_exists('Tx_Extbase_Service_Extension') === TRUE) { $pluginName = $this->objectManager->get('Tx_Extbase_Service_Extension')->getPluginNameByAction($extensionName, $controllerName, 'list'); } else { $pluginName = Tx_Extbase_Utility_Extension::getPluginNameByAction($extensionName, $controllerName, 'list'); } return $pluginName; }