mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Added exception for enumerated array (#9644)
\SilverStripe\View\ArrayData::__construct() throws error when passed an enumerated array #9644
This commit is contained in:
parent
009ae3ee4f
commit
a380cc7444
@ -33,10 +33,16 @@ class ArrayData extends ViewableData
|
||||
{
|
||||
if (is_object($value)) {
|
||||
$this->array = get_object_vars($value);
|
||||
} elseif (ArrayLib::is_associative($value)) {
|
||||
$this->array = $value;
|
||||
} elseif (is_array($value) && count($value) === 0) {
|
||||
$this->array = [];
|
||||
} elseif (is_array($value)) {
|
||||
if (ArrayLib::is_associative($value)) {
|
||||
$this->array = $value;
|
||||
} elseif (count($value) === 0) {
|
||||
$this->array = array();
|
||||
} else {
|
||||
$message = 'Parameter to ArrayData constructor needs to be an object or associative array,
|
||||
enumareted array passed instead. Did you mean to use ArrayList?';
|
||||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
} else {
|
||||
$message = 'Parameter to ArrayData constructor needs to be an object or associative array';
|
||||
throw new InvalidArgumentException($message);
|
||||
|
Loading…
x
Reference in New Issue
Block a user