Render a link to a specific module
public render ( string $path, string $action = null, array $arguments = [], string $section = '', string $format = '', array $additionalParams = [], boolean $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [] ) : string | ||
$path | string | Target module path |
$action | string | Target module action |
$arguments | array | Arguments |
$section | string | The anchor to be added to the URI |
$format | string | The requested format, e.g. ".html" |
$additionalParams | array | additional query parameters that won't be prefixed like $arguments (overrule $arguments) |
$addQueryString | boolean | If set, the current query parameters will be kept in the URI |
$argumentsToBeExcludedFromQueryString | array | arguments to be removed from the URI. Only active if $addQueryString = TRUE |
return | string | The rendered link |
/** * Render a link to a specific module * * @param string $path Target module path * @param string $action Target module action * @param array $arguments Arguments * @param string $section The anchor to be added to the URI * @param string $format The requested format, e.g. ".html" * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments) * @param boolean $addQueryString If set, the current query parameters will be kept in the URI * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE * @return string The rendered link * @throws \Neos\FluidAdaptor\Core\ViewHelper\Exception */ public function render($path, $action = null, $arguments = array(), $section = '', $format = '', array $additionalParams = array(), $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array()) { $this->uriModuleViewHelper->setRenderingContext($this->renderingContext); $uri = $this->uriModuleViewHelper->render($path, $action, $arguments, $section, $format, $additionalParams, $addQueryString, $argumentsToBeExcludedFromQueryString); if ($uri !== null) { $this->tag->addAttribute('href', $uri); } $this->tag->setContent($this->renderChildren()); $this->tag->forceClosingTag(true); return $this->tag->render(); }
/** * @test */ public function callingRenderAssignsVariablesCorrectlyToUriBuilder() { $this->uriBuilder->expects($this->once())->method('setSection')->with('section')->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArguments')->with(array('additionalParams'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setArgumentsToBeExcludedFromQueryString')->with(array('argumentsToBeExcludedFromQueryString'))->will($this->returnSelf()); $this->uriBuilder->expects($this->once())->method('setFormat')->with('format')->will($this->returnSelf()); $expectedModifiedArguments = array('module' => 'the/path', 'moduleArguments' => array('arguments', '@action' => 'action')); $this->uriBuilder->expects($this->once())->method('uriFor')->with('index', $expectedModifiedArguments); // fallback for the method chaining of the URI builder $this->uriBuilder->expects($this->any())->method($this->anything())->will($this->returnValue($this->uriBuilder)); $this->viewHelper->render('the/path', 'action', array('arguments'), 'section', 'format', array('additionalParams'), true, array('argumentsToBeExcludedFromQueryString')); }