Skip to content

Commit

Permalink
Revert "FIX Fluent now respects existing base URL prefixes in UR… (#539)
Browse files Browse the repository at this point in the history
Revert "FIX Fluent now respects existing base URL prefixes in URL segment fields when no fluent domain exists"
  • Loading branch information
ScopeyNZ authored Jul 30, 2019
2 parents 17b8d8c + 3a37dca commit 68b1b19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions src/Extension/FluentSiteTreeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ protected function addLocalePrefixToUrlSegment(FieldList $fields)
return $this;
}

// Mock frontend and set link to parent object / page
FluentState::singleton()
->withState(function (FluentState $tempState) use ($segmentField) {
// Mock frontend and get link to parent object / page
$baseURL = FluentState::singleton()
->withState(function (FluentState $tempState) {
$tempState->setIsDomainMode(true);
$tempState->setIsFrontend(true);

Expand All @@ -264,14 +264,15 @@ protected function addLocalePrefixToUrlSegment(FieldList $fields)
if ($domain) {
$parentBase = Controller::join_links($domain->Link(), Director::baseURL());
} else {
// Use any existing pre-configured base URL prefix for the field
$parentBase = $segmentField->getURLPrefix();
$parentBase = Director::absoluteBaseURL();
}

// Join base / relative links
$segmentField->setURLPrefix(Controller::join_links($parentBase, $parentRelative));
return Controller::join_links($parentBase, $parentRelative);
});


$segmentField->setURLPrefix($baseURL);
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/php/Extension/FluentSiteTreeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function (FluentState $newState) use ($localeCode, $fixture, $expected) {
$fields = $this->objFromFixture(Page::class, $fixture)->getCMSFields();

/** @var SiteTreeURLSegmentField $segmentField */
$segmentField = $fields->dataFieldByName('URLSegment');
$segmentField = $fields->fieldByName('Root.Main.URLSegment');
$this->assertInstanceOf(SiteTreeURLSegmentField::class, $segmentField);

$this->assertSame($expected, $segmentField->getURLPrefix());
Expand Down

0 comments on commit 68b1b19

Please sign in to comment.