Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "FIX Fluent now respects existing base URL prefixes in URL segment fields when no fluent domain exists" #539

Merged
merged 1 commit into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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