[Flow] Correct frontend urls with CLI, StandaloneView, ActionViewHelper?
Bastian Waidelich
bastian at typo3.org
Wed Sep 4 10:49:15 CEST 2013
Tobias Pinnekamp wrote:
Hi Tobias,
> I want to send mails with a CommandController rendered by a
> StandaloneView. I've got everything running but the generated links in
> the rendered view start with "http://localhost./index.php/...". The rest
> of the link is just fine. But I think the problem is the CLI context.
Here's how you can solve this:
/**
* @Flow\Inject
* @var \TYPO3\Flow\Security\Context
*/
protected $securityContext;
/**
* @Flow\Inject
* @var \TYPO3\Flow\Configuration\ConfigurationManager
*/
protected $configurationManager;
/**
* @Flow\Inject
* @var \TYPO3\Flow\Mvc\Routing\RouterInterface
*/
protected $router;
/**
* @return void
*/
public function someCommand() {
// initialize router
$routesConfiguration =
$this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
$this->router->setRoutesConfiguration($routesConfiguration);
// initialize view
$standaloneView = new \TYPO3\Fluid\View\StandaloneView();
$request = $standaloneView->getRequest();
// inject TYPO3.Flow settings to fetch base URI configuration
$flowSettings =
$this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS,
'TYPO3.Flow');
$request->getHttpRequest()->injectSettings($flowSettings);
// set package key (so you can omit the "package" argument in link/uri
ViewHelpers
$request->setControllerPackageKey('Your.Package');
// ...
}
HTH
--
Bastian Waidelich
--
Core Developer Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the Flow
mailing list