*/
protected $createAbsoluteUri = FALSE;
+ /**
+ * @var string
+ */
+ protected $absoluteUriScheme = NULL;
+
/**
* @var boolean
*/
/**
* Specifies the format of the target (e.g. "html" or "xml")
*
- * @param string $section
+ * @param string $format
* @return Tx_Extbase_MVC_Web_Routing_UriBuilder the current UriBuilder to allow method chaining
* @api
*/
return $this->createAbsoluteUri;
}
+ /**
+ * @return string
+ */
+ public function getAbsoluteUriScheme() {
+ return $this->absoluteUriScheme;
+ }
+
+ /**
+ * Sets the scheme that should be used for absolute URIs in FE mode
+ *
+ * @param string $absoluteUriScheme the scheme to be used for absolute URIs
+ * @return Tx_Extbase_MVC_Web_Routing_UriBuilder the current UriBuilder to allow method chaining
+ */
+ public function setAbsoluteUriScheme($absoluteUriScheme) {
+ $this->absoluteUriScheme = $absoluteUriScheme;
+ return $this;
+ }
+
/**
* If set, the current query parameters will be merged with $this->arguments. Defaults to FALSE.
*
if ($this->createAbsoluteUri === TRUE) {
$typolinkConfiguration['forceAbsoluteUrl'] = TRUE;
+ if ($this->absoluteUriScheme !== NULL) {
+ $typolinkConfiguration['forceAbsoluteUrl.']['scheme'] = $this->absoluteUriScheme;
+ }
}
$uri = $this->contentObject->typoLink_URL($typolinkConfiguration);
->setSection('testSection')
->setFormat('testFormat')
->setCreateAbsoluteUri(TRUE)
+ ->setAbsoluteUriScheme('https')
->setAddQueryString(TRUE)
->setArgumentsToBeExcludedFromQueryString(array('test' => 'addQueryStringExcludeArguments'))
->setArgumentPrefix('testArgumentPrefix')
$this->assertEquals('testSection', $this->uriBuilder->getSection());
$this->assertEquals('testFormat', $this->uriBuilder->getFormat());
$this->assertEquals(TRUE, $this->uriBuilder->getCreateAbsoluteUri());
+ $this->assertEquals('https', $this->uriBuilder->getAbsoluteUriScheme());
$this->assertEquals(TRUE, $this->uriBuilder->getAddQueryString());
$this->assertEquals(array('test' => 'addQueryStringExcludeArguments'), $this->uriBuilder->getArgumentsToBeExcludedFromQueryString());
$this->assertEquals('testArgumentPrefix', $this->uriBuilder->getArgumentPrefix());
$this->assertSame($expectedResult, $actualResult);
}
+ /**
+ * @test
+ */
+ public function buildFrontendUriSetsAbsoluteUriSchemeIfSpecified() {
+ $uriBuilder = $this->getAccessibleMock('Tx_Extbase_MVC_Web_Routing_UriBuilder', array('buildTypolinkConfiguration'));
+ $uriBuilder->_set('contentObject', $this->mockContentObject);
+ $uriBuilder->expects($this->once())->method('buildTypolinkConfiguration')->will($this->returnValue(array('foo' => 'bar')));
+
+ $this->mockContentObject->expects($this->once())->method('typoLink_URL')->with(array('foo' => 'bar', 'forceAbsoluteUrl' => TRUE, 'forceAbsoluteUrl.' => array('scheme' => 'someScheme')))->will($this->returnValue('http://baseuri/relative/uri'));
+ $uriBuilder->setCreateAbsoluteUri(TRUE);
+ $uriBuilder->setAbsoluteUriScheme('someScheme');
+
+ $expectedResult = 'http://baseuri/relative/uri';
+ $actualResult = $uriBuilder->buildFrontendUri();
+ $this->assertSame($expectedResult, $actualResult);
+ }
+
+ /**
+ * @test
+ */
+ public function buildFrontendUriDoesNotSetAbsoluteUriSchemeIfCreateAbsoluteUriIsFalse() {
+ $uriBuilder = $this->getAccessibleMock('Tx_Extbase_MVC_Web_Routing_UriBuilder', array('buildTypolinkConfiguration'));
+ $uriBuilder->_set('contentObject', $this->mockContentObject);
+ $uriBuilder->expects($this->once())->method('buildTypolinkConfiguration')->will($this->returnValue(array('foo' => 'bar')));
+
+ $this->mockContentObject->expects($this->once())->method('typoLink_URL')->with(array('foo' => 'bar'))->will($this->returnValue('http://baseuri/relative/uri'));
+ $uriBuilder->setCreateAbsoluteUri(FALSE);
+ $uriBuilder->setAbsoluteUriScheme('someScheme');
+
+ $expectedResult = 'http://baseuri/relative/uri';
+ $actualResult = $uriBuilder->buildFrontendUri();
+ $this->assertSame($expectedResult, $actualResult);
+ }
+
/**
* @test
*/