public function TokenReplacerBase::object_to_array in Forena Reports 8
Same name and namespace in other branches
- 7.5 src/Token/TokenReplacerBase.php \Drupal\forena\Token\TokenReplacerBase::object_to_array()
Convert an object into an array
* Iterates the object and builds an array of strings from it. If the object appears to be an xml object and has an attributes method, do the same for it.
Parameters
mixed $data:
Return value
array array representation of object.
File
- src/
Token/ TokenReplacerBase.php, line 153 - FrXSytnaxEngine defines how regular expression procesing/token substitution takes place. It includes support for passing in a formatter oobject that will escape strings properly before substituting them.
Class
- TokenReplacerBase
- Base class for token replacements. @package Drupal\forena\Token
Namespace
Drupal\forena\TokenCode
public function object_to_array($data) {
if (is_object($data)) {
$ar = array();
foreach ($data as $key => $value) {
$ar[$key] = (string) $value;
}
if (method_exists($data, 'attributes')) {
foreach ($data
->attributes() as $key => $value) {
$ar[$key] = (string) $value;
}
}
return $ar;
}
else {
return $data;
}
}