/** * Builds a web request object from the raw HTTP information and the configuration * * @return Tx_Extbase_MVC_Web_Request The web request as an object */ public function build() { $this->loadDefaultValues(); $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($this->extensionName, $this->pluginName); $parameters = t3lib_div::_GPmerged($pluginNamespace); if (is_string($parameters['controller']) && array_key_exists($parameters['controller'], $this->allowedControllerActions)) { $controllerName = filter_var($parameters['controller'], FILTER_SANITIZE_STRING); } elseif (!empty($this->defaultControllerName)) { $controllerName = $this->defaultControllerName; } else { throw new Tx_Extbase_MVC_Exception('The default controller can not be determined.<br />' . 'Please check for Tx_Extbase_Utility_Extension::configurePlugin() in your ext_localconf.php.', 1295479650); } $allowedActions = $this->allowedControllerActions[$controllerName]; if (is_string($parameters['action']) && is_array($allowedActions) && in_array($parameters['action'], $allowedActions)) { $actionName = filter_var($parameters['action'], FILTER_SANITIZE_STRING); } elseif (!empty($this->defaultActionName)) { $actionName = $this->defaultActionName; } else { throw new Tx_Extbase_MVC_Exception('The default action can not be determined for controller "' . $controllerName . '".<br />' . 'Please check Tx_Extbase_Utility_Extension::configurePlugin() in your ext_localconf.php.', 1295479651); } $request = $this->objectManager->create('Tx_Extbase_MVC_Web_Request'); $request->setPluginName($this->pluginName); $request->setControllerExtensionName($this->extensionName); $request->setControllerName($controllerName); $request->setControllerActionName($actionName); $request->setRequestURI(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')); $request->setBaseURI(t3lib_div::getIndpEnv('TYPO3_SITE_URL')); $request->setMethod(isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : NULL); if (is_string($parameters['format']) && strlen($parameters['format'])) { $request->setFormat(filter_var($parameters['format'], FILTER_SANITIZE_STRING)); } foreach ($parameters as $argumentName => $argumentValue) { $request->setArgument($argumentName, $argumentValue); } return $request; }
/** * Initialize the Widget Context, before the Render method is called. * * @return void * @author Sebastian Kurfürst <*****@*****.**> */ private function initializeWidgetContext() { $this->widgetContext->setWidgetConfiguration($this->getWidgetConfiguration()); $this->initializeWidgetIdentifier(); $controllerObjectName = $this->controller instanceof Tx_Fluid_AOP_ProxyInterface ? $this->controller->FLOW3_AOP_Proxy_getProxyTargetClassName() : get_class($this->controller); $this->widgetContext->setControllerObjectName($controllerObjectName); $extensionName = $this->controllerContext->getRequest()->getControllerExtensionName(); $pluginName = $this->controllerContext->getRequest()->getPluginName(); $this->widgetContext->setParentExtensionName($extensionName); $this->widgetContext->setParentPluginName($pluginName); $pluginNamespace = Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName); $this->widgetContext->setParentPluginNamespace($pluginNamespace); $this->widgetContext->setWidgetViewHelperClassName(get_class($this)); if ($this->ajaxWidget === TRUE) { $this->ajaxWidgetContextHolder->store($this->widgetContext); } }
/** * 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(); }
/** * @test */ public function pluginNamespaceCanBeOverridden() { $mockConfigurationManager = $this->getMock('Tx_Extbase_Configuration_ConfigurationManagerInterface'); $mockConfigurationManager->expects($this->once())->method('getConfiguration')->with(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'SomeExtension', 'SomePlugin')->will($this->returnValue(array('view' => array('pluginNamespace' => 'overridden_plugin_namespace')))); $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); $expectedResult = 'overridden_plugin_namespace'; $actualResult = Tx_Extbase_Utility_Extension::getPluginNamespace('SomeExtension', 'SomePlugin'); $this->assertEquals($expectedResult, $actualResult); }
/** * Retrieves the default field name prefix for this form * * @return string default field name prefix */ protected function getDefaultFieldNamePrefix() { $request = $this->controllerContext->getRequest(); if ($this->arguments->hasArgument('extensionName')) { $extensionName = $this->arguments['extensionName']; } else { $extensionName = $request->getControllerExtensionName(); } if ($this->arguments->hasArgument('pluginName')) { $pluginName = $this->arguments['pluginName']; } else { $pluginName = $request->getPluginName(); } return Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName); }
/** * Get the plugin namespace (for URIs) based on Model Object * * @param mixed $object * @return string * @api */ public function getPluginNamespace($object) { $extensionName = $this->getExtensionName($object); $pluginName = $this->getPluginName($object); if (class_exists('Tx_Extbase_Service_Extension') === TRUE) { return $this->objectManager->get('Tx_Extbase_Service_Extension')->getPluginNamespace($extensionName, $pluginName); } else { return Tx_Extbase_Utility_Extension::getPluginNamespace($extensionName, $pluginName); } }