mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #9650 from dylangrech92/patch-1
Added exception for enumerated array (#9644)
This commit is contained in:
commit
85242b1efe
@ -33,12 +33,18 @@ class ArrayData extends ViewableData
|
|||||||
{
|
{
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
$this->array = get_object_vars($value);
|
$this->array = get_object_vars($value);
|
||||||
} elseif (ArrayLib::is_associative($value)) {
|
} elseif (is_array($value)) {
|
||||||
|
if (ArrayLib::is_associative($value)) {
|
||||||
$this->array = $value;
|
$this->array = $value;
|
||||||
} elseif (is_array($value) && count($value) === 0) {
|
} elseif (count($value) === 0) {
|
||||||
$this->array = [];
|
$this->array = [];
|
||||||
} else {
|
} else {
|
||||||
$message = 'Parameter to ArrayData constructor needs to be an object or associative array';
|
$message = 'ArrayData constructor expects an object or associative array,
|
||||||
|
enumerated array passed instead. Did you mean to use ArrayList?';
|
||||||
|
throw new InvalidArgumentException($message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$message = 'ArrayData constructor expects an object or associative array';
|
||||||
throw new InvalidArgumentException($message);
|
throw new InvalidArgumentException($message);
|
||||||
}
|
}
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
Loading…
Reference in New Issue
Block a user