mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.3' into 4
This commit is contained in:
commit
fc6213c293
@ -388,6 +388,10 @@ trait Extensible
|
||||
if (!$strict && is_subclass_of($extension, $requiredExtension)) {
|
||||
return true;
|
||||
}
|
||||
$inst = Injector::inst()->get($extension);
|
||||
if ($inst instanceof $requiredExtension) {
|
||||
return $strict ? strcasecmp(get_class($inst), $requiredExtension) === 0 : true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -88,7 +88,7 @@ class GridFieldLevelup implements GridField_HTMLProvider
|
||||
$template = SSViewer::get_templates_by_class($this, '', __CLASS__);
|
||||
return array(
|
||||
'before' => $forTemplate->renderWith($template),
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public function setAttributes($attrs)
|
||||
|
@ -140,11 +140,11 @@ if (!defined('BASE_URL')) {
|
||||
) {
|
||||
$requestURI = $_SERVER['REQUEST_URI'];
|
||||
// Check if /base/public or /base are in the request
|
||||
foreach ([$baseURL, dirname($baseURL)] as $candidate) {
|
||||
if (stripos($requestURI, $candidate) === 0) {
|
||||
return $candidate;
|
||||
}
|
||||
foreach ([$baseURL, dirname($baseURL)] as $candidate) {
|
||||
if (stripos($requestURI, $candidate) === 0) {
|
||||
return $candidate;
|
||||
}
|
||||
}
|
||||
// Ambiguous
|
||||
return '';
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use SilverStripe\Core\Tests\ObjectTest\ExtendTest1;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtendTest2;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtendTest3;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtendTest4;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtendTest5;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtensionRemoveTest;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtensionTest;
|
||||
use SilverStripe\Core\Tests\ObjectTest\ExtensionTest2;
|
||||
@ -289,6 +290,13 @@ class ObjectTest extends SapphireTest
|
||||
$objectTest_ExtensionTest->hasExtension(ExtendTest3::class),
|
||||
"Extensions are detected with instance hasExtension() when added through add_extension()"
|
||||
);
|
||||
|
||||
// load in a custom implementation
|
||||
Injector::inst()->registerService(new ExtendTest5(), ExtendTest4::class);
|
||||
$this->assertTrue(
|
||||
ExtensionTest3::has_extension(ExtendTest5::class),
|
||||
"Injected sub-extensions are detected with static has_extension() when added through add_extension()"
|
||||
);
|
||||
|
||||
// @todo At the moment, this does NOT remove the extension due to parameterized naming,
|
||||
// meaning the extension will remain added in further test cases
|
||||
|
11
tests/php/Core/ObjectTest/ExtendTest5.php
Normal file
11
tests/php/Core/ObjectTest/ExtendTest5.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Core\Tests\ObjectTest;
|
||||
|
||||
class ExtendTest5 extends ExtendTest4
|
||||
{
|
||||
public function extendableMethod($argument = null)
|
||||
{
|
||||
return "ExtendTest5($argument)";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user