Convert to array if JSON isn't one already.

This commit is contained in:
Markus Birth 2016-07-09 20:40:46 +02:00
parent e024bdba85
commit 4df5b6896c

View File

@ -16,9 +16,12 @@ class FieldDefinition
if (!file_exists($definitionFile)) {
throw new \Exception('File ' . $definitionFile . ' not found!');
}
$fieldDataJson = file_get_contents($definitionFile);
/** @var array */
$this->fieldData = json_decode($fieldDataJson, true);
$fieldDataJson = file_get_contents($definitionFile);
$fieldData = json_decode($fieldDataJson, true);
if (!is_array($fieldData)) {
$fieldData = array($fieldData);
}
$this->fieldData = $fieldData;
}
public function getFieldData()