mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
NEW Allow GridFieldConfig::addComponents to accept an array (#7844)
This commit is contained in:
parent
e0e8ca0ee6
commit
dd82820242
@ -68,12 +68,12 @@ class GridFieldConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GridFieldComponent $component,... One or more components
|
* @param GridFieldComponent|GridFieldComponent[] $component,... One or more components, or an array of components
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function addComponents($component = null)
|
public function addComponents($component = null)
|
||||||
{
|
{
|
||||||
$components = func_get_args();
|
$components = is_array($component) ? $component : func_get_args();
|
||||||
foreach ($components as $component) {
|
foreach ($components as $component) {
|
||||||
$this->addComponent($component);
|
$this->addComponent($component);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,19 @@ class GridFieldConfigTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAddComponentsByArray()
|
||||||
|
{
|
||||||
|
$config = GridFieldConfig::create()
|
||||||
|
->addComponents([
|
||||||
|
$c1 = new MyComponent(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$c1,
|
||||||
|
$config->getComponentByType(MyComponent::class)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function testRemoveComponents()
|
public function testRemoveComponents()
|
||||||
{
|
{
|
||||||
$config = GridFieldConfig::create()
|
$config = GridFieldConfig::create()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user