mirror of
https://github.com/wilr/silverstripe-googlesitemaps.git
synced 2024-10-22 11:05:48 +02:00
Merge pull request #153 from wilr/wilr-patch-1
Support falsey values in alter (Fixes #152)
This commit is contained in:
commit
764a8f5bb2
@ -52,13 +52,18 @@ class GoogleSitemapExtension extends DataExtension
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow override. In this case, since this can return multiple results, we'll use an "and" based policy.
|
// Allow override. invokeWithExtensions will either return a single result (true|false) if defined on the object
|
||||||
// That is if any value is false then the current value will be false. Only only if all are true will we
|
// or an array if on extensions.
|
||||||
// then return true.
|
|
||||||
$override = $this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can);
|
$override = $this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can);
|
||||||
|
|
||||||
if ($override) {
|
if ($override !== null) {
|
||||||
$can = min($override, $can);
|
if (is_array($override)) {
|
||||||
|
if (!empty($override)) {
|
||||||
|
$can = min($override, $can);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$can = $override;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $can;
|
return $can;
|
||||||
|
@ -60,6 +60,7 @@ class GoogleSitemapTest extends FunctionalTest
|
|||||||
$this->assertFalse($unused->canIncludeInGoogleSitemap());
|
$this->assertFalse($unused->canIncludeInGoogleSitemap());
|
||||||
|
|
||||||
$used = $this->objFromFixture(TestDataObject::class, 'DataObjectTest2');
|
$used = $this->objFromFixture(TestDataObject::class, 'DataObjectTest2');
|
||||||
|
|
||||||
$this->assertTrue($used->canIncludeInGoogleSitemap());
|
$this->assertTrue($used->canIncludeInGoogleSitemap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user