diff --git a/_config/config.yml b/_config/config.yml index 1f778d13..76729a0a 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -4,3 +4,6 @@ Name: linkfield SilverStripe\Admin\LeftAndMain: extensions: - SilverStripe\LinkField\Extensions\LeftAndMainExtension +SilverStripe\Admin\Forms\UsedOnTable: + extensions: + - SilverStripe\LinkField\Extensions\UsedOnTableExtension diff --git a/src/Extensions/UsedOnTableExtension.php b/src/Extensions/UsedOnTableExtension.php new file mode 100644 index 00000000..66815728 --- /dev/null +++ b/src/Extensions/UsedOnTableExtension.php @@ -0,0 +1,32 @@ +Owner(); + if (!$owner?->exists()) { + return; + } + $ancestorDataObjects[] = $owner; + if (!class_exists(BaseElement::class) || !is_a($owner, BaseElement::class)) { + return; + } + $page = $owner->hasExtension(TopPageExtension::class) ? $owner->getTopPage() : $owner->getPage(); + if (!$page?->exists()) { + return; + } + $ancestorDataObjects[] = $page; + } +}