mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.2' into 4.3
This commit is contained in:
commit
0ba275cb40
@ -959,6 +959,9 @@ warnings:
|
|||||||
'Object':
|
'Object':
|
||||||
message: 'Replaced with traits'
|
message: 'Replaced with traits'
|
||||||
url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#object-replace'
|
url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#object-replace'
|
||||||
|
'SS_Object':
|
||||||
|
message: 'Replaced with traits'
|
||||||
|
url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#object-replace'
|
||||||
'SS_Log':
|
'SS_Log':
|
||||||
message: 'Replaced with a PSR-3 logger'
|
message: 'Replaced with a PSR-3 logger'
|
||||||
url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#psr3-logging'
|
url: 'https://docs.silverstripe.org/en/4/changelogs/4.0.0#psr3-logging'
|
||||||
|
@ -13,6 +13,7 @@ use SilverStripe\Core\ClassInfo;
|
|||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Core\Environment;
|
use SilverStripe\Core\Environment;
|
||||||
use SilverStripe\Dev\Deprecation;
|
use SilverStripe\Dev\Deprecation;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple injection manager that manages creating objects and injecting
|
* A simple injection manager that manages creating objects and injecting
|
||||||
@ -581,6 +582,14 @@ class Injector implements ContainerInterface
|
|||||||
$constructorParams = $spec['constructor'];
|
$constructorParams = $spec['constructor'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we're dealing with a DataObject singleton without specific constructor params, pass through Singleton
|
||||||
|
// flag as second argument
|
||||||
|
if ((!$type || $type !== self::PROTOTYPE)
|
||||||
|
&& empty($constructorParams)
|
||||||
|
&& is_subclass_of($class, DataObject::class)) {
|
||||||
|
$constructorParams = array(null, true);
|
||||||
|
}
|
||||||
|
|
||||||
$factory = isset($spec['factory']) ? $this->get($spec['factory']) : $this->getObjectCreator();
|
$factory = isset($spec['factory']) ? $this->get($spec['factory']) : $this->getObjectCreator();
|
||||||
$object = $factory->create($class, $constructorParams);
|
$object = $factory->create($class, $constructorParams);
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ class GridField_FormAction extends FormAction
|
|||||||
// will strip it from the requests
|
// will strip it from the requests
|
||||||
'name' => 'action_gridFieldAlterAction' . '?' . http_build_query($actionData),
|
'name' => 'action_gridFieldAlterAction' . '?' . http_build_query($actionData),
|
||||||
'data-url' => $this->gridField->Link(),
|
'data-url' => $this->gridField->Link(),
|
||||||
|
'type' => "button",
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,51 @@ class DataObjectTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider provideSingletons
|
||||||
|
*/
|
||||||
|
public function testSingleton($inst, $defaultValue, $altDefaultValue)
|
||||||
|
{
|
||||||
|
$inst = $inst();
|
||||||
|
// Test that populateDefaults() isn't called on singletons
|
||||||
|
// which can lead to SQL errors during build, and endless loops
|
||||||
|
if ($defaultValue) {
|
||||||
|
$this->assertEquals($defaultValue, $inst->MyFieldWithDefault);
|
||||||
|
} else {
|
||||||
|
$this->assertEmpty($inst->MyFieldWithDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($altDefaultValue) {
|
||||||
|
$this->assertEquals($altDefaultValue, $inst->MyFieldWithAltDefault);
|
||||||
|
} else {
|
||||||
|
$this->assertEmpty($inst->MyFieldWithAltDefault);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideSingletons()
|
||||||
|
{
|
||||||
|
// because PHPUnit evalutes test providers *before* setUp methods
|
||||||
|
// any extensions added in the setUp methods won't be available
|
||||||
|
// we must return closures to generate the arguments at run time
|
||||||
|
return array(
|
||||||
|
'create() static method' => array(function () {
|
||||||
|
return DataObjectTest\Fixture::create();
|
||||||
|
}, 'Default Value', 'Default Value'),
|
||||||
|
'New object creation' => array(function () {
|
||||||
|
return new DataObjectTest\Fixture();
|
||||||
|
}, 'Default Value', 'Default Value'),
|
||||||
|
'singleton() function' => array(function () {
|
||||||
|
return singleton(DataObjectTest\Fixture::class);
|
||||||
|
}, null, null),
|
||||||
|
'singleton() static method' => array(function () {
|
||||||
|
return DataObjectTest\Fixture::singleton();
|
||||||
|
}, null, null),
|
||||||
|
'Manual constructor args' => array(function () {
|
||||||
|
return new DataObjectTest\Fixture(null, true);
|
||||||
|
}, null, null),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testDb()
|
public function testDb()
|
||||||
{
|
{
|
||||||
$schema = DataObject::getSchema();
|
$schema = DataObject::getSchema();
|
||||||
|
Loading…
Reference in New Issue
Block a user