From 07f282123297068d40e7ce764a280e295a6f76a1 Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Mon, 8 Apr 2024 16:35:43 +1200 Subject: [PATCH] PR feedback. --- src/Extension/Traits/FluentObjectTrait.php | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/Extension/Traits/FluentObjectTrait.php b/src/Extension/Traits/FluentObjectTrait.php index fc07196b..6206160c 100644 --- a/src/Extension/Traits/FluentObjectTrait.php +++ b/src/Extension/Traits/FluentObjectTrait.php @@ -125,23 +125,25 @@ protected function updateFluentCMSFields(FieldList $fields) $url = $owner->CMSEditLink(); $url = Director::makeRelative($url); - $summaryColumns['Title'] = [ - 'title' => 'Title', - 'callback' => function (Locale $object) use ($url, $params): ?DBField { - if (!$object->RecordLocale()) { - return null; + if ($url) { + $summaryColumns['Title'] = [ + 'title' => 'Title', + 'callback' => function (Locale $object) use ($url, $params): ?DBField { + if (!$object->RecordLocale()) { + return null; + } + + $recordLocale = $object->RecordLocale(); + $locale = $recordLocale->getLocale(); + $params['l'] = $locale; + $localeLink = Controller::join_links($url, '?' . http_build_query($params)); + $localeTitle = Convert::raw2xml($recordLocale->getTitle()); + $render = sprintf('%s', $localeLink, $localeTitle); + + return DBField::create_field('HTMLVarchar', $render); } - - $recordLocale = $object->RecordLocale(); - $locale = $recordLocale->getLocale(); - $params['l'] = $locale; - $localeLink = Controller::join_links($url, '?' . http_build_query($params)); - $localeTitle = Convert::raw2xml($recordLocale->getTitle()); - $render = sprintf('%s', $localeLink, $localeTitle); - - return DBField::create_field('HTMLVarchar', $render); - } - ]; + ]; + } } // Let extensions override columns