From 5228024ba5cce3988abf1ea727b0efdecb5d373d Mon Sep 17 00:00:00 2001 From: Patrick Nelson Date: Tue, 23 Feb 2016 17:52:15 -0500 Subject: [PATCH] FIX for #78 to workaround ->alterCanIncludeInGoogleSitemap() not working due to core bug with ->invokeWithExtensions() not allowing references. --- code/extensions/GoogleSitemapExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/extensions/GoogleSitemapExtension.php b/code/extensions/GoogleSitemapExtension.php index 6db716c..8e95992 100644 --- a/code/extensions/GoogleSitemapExtension.php +++ b/code/extensions/GoogleSitemapExtension.php @@ -33,7 +33,13 @@ class GoogleSitemapExtension extends DataExtension $can = $this->owner->getGooglePriority(); } - $this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can); + // Allow override. In this case, since this can return multiple results, we'll use an "and" based policy. That is + // if any value is false then the current value will be false. Only only if all are true will we then return true. + $override = $this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can); + if ($override) { + $can = min($override); + } + return $can; }