diff --git a/src/Extensions/GoogleSitemapExtension.php b/src/Extensions/GoogleSitemapExtension.php index e81eac3..1e89eba 100644 --- a/src/Extensions/GoogleSitemapExtension.php +++ b/src/Extensions/GoogleSitemapExtension.php @@ -52,13 +52,18 @@ class GoogleSitemapExtension extends DataExtension return false; } - // 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. + // Allow override. invokeWithExtensions will either return a single result (true|false) if defined on the object + // or an array if on extensions. $override = $this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can); - if ($override) { - $can = min($override, $can); + if ($override !== null) { + if (is_array($override)) { + if (!empty($override)) { + $can = min($override, $can); + } + } else { + $can = $override; + } } return $can; diff --git a/tests/GoogleSitemapTest.php b/tests/GoogleSitemapTest.php index 56f022b..9faa31a 100644 --- a/tests/GoogleSitemapTest.php +++ b/tests/GoogleSitemapTest.php @@ -60,6 +60,7 @@ class GoogleSitemapTest extends FunctionalTest $this->assertFalse($unused->canIncludeInGoogleSitemap()); $used = $this->objFromFixture(TestDataObject::class, 'DataObjectTest2'); + $this->assertTrue($used->canIncludeInGoogleSitemap()); }