You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// I want the Resource DataObject to queue an update to its own URL when changed.class ResourceExtension extends DataExtension implements StaticallyPublishable, StaticPublishingTrigger
{
publicfunctionurlsToCache()
{
return [$this->owner->getDetailPageAbsoluteLink() => 0];
}
publicfunctionobjectsToUpdate($context)
{
return$this->owner;
}
}
What if there was a loop over extensions that checked for this interface?
$extensionImplementsInterface = false;
foreach ($siteTree->get_extensions() as$extension) {
if (new$extensioninstanceof StaticPublishingTrigger) {
$extensionImplementsInterface = true;
break;
}
}
// The page does not include the required extension, and it doesn't implement a Triggerif (!$siteTree->hasExtension(PublishableSiteTree::class) && !($siteTreeinstanceof StaticPublishingTrigger) && !$extensionImplementsInterface) {
return;
}
What if there was a loop over extensions that checked for this interface?
Not neecssary - you can do $record->hasExtension(StaticPublishingTrigger::class) which will check for extensions that implement that interface.
Assuming implementing the interface on an extension class actually works, I see no reason not to allow this. Feel free to submit a PR including unit tests that validate triggers work as expected when provided through an extension.
Description
I would like to add StaticPublishingTrigger to a DataObject through a DataExtension, but StaticPublishingTrigger checks if the original DataObject implements StaticPublishingTrigger.
What if there was a loop over extensions that checked for this interface?
Additional context or points of discussion
This is how I have the extensions applied
Validations
The text was updated successfully, but these errors were encountered: