Skip to content

Commit

Permalink
Settings for SiteTree objects
Browse files Browse the repository at this point in the history
  • Loading branch information
blueo committed May 2, 2024
1 parent c5a5489 commit 2b63d9b
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions src/Extensions/SearchServiceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,18 @@ public function __construct(
$this->setBatchProcessor($batchProcessor);
}

/**
* General DataObject Search settings
*
* @param FieldList $fields
* @return void
*/
public function updateCMSFields(FieldList $fields): void
{
if ($this->owner instanceof SiteTree) {
return;
}

if (!$this->getConfiguration()->isEnabled()) {
return;
}
Expand All @@ -75,12 +85,33 @@ public function updateCMSFields(FieldList $fields): void
_t(self::class . '.LastIndexed', 'Last indexed in search')
);

if ($this->owner instanceof SiteTree) {
$fields->addFieldToTab('Root.Main', $searchIndexedField);
} else {
$fields->push($showInSearchField);
$fields->push($searchIndexedField);
$fields->push($showInSearchField);
$fields->push($searchIndexedField);

}

/**
* Specific settings for SiteTree
*
* @param FieldList $fields
* @return void
*/
public function updateSettingsFields(FieldList $fields): void
{
if (!$this->owner instanceof SiteTree) {
return;
}

if (!$this->getConfiguration()->isEnabled()) {
return;
}

$searchIndexedField = ReadonlyField::create(
'SearchIndexed',
_t(self::class . '.LastIndexed', 'Last indexed in search')
);

$fields->insertAfter('ShowInSearch', $searchIndexedField);
}

/**
Expand Down

0 comments on commit 2b63d9b

Please sign in to comment.