Skip to content

Commit

Permalink
Add support to serialize Object properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Sep 25, 2017
1 parent 588c509 commit 71b1136
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,19 @@ protected function initObjectProperties()
*/
protected function getElements()
{
return array_intersect_key(get_object_vars($this), array_filter($this->_definedProperties));
$properties = array_intersect_key(get_object_vars($this), array_filter($this->_definedProperties));

$elements = [];
foreach ($properties as $offset => $value) {
$methodName = "offsetSerialize_{$offset}";
if (method_exists($this, $methodName)) {
$elements[$offset] = $this->{$methodName}($value);
} else {
$elements[$offset] = $value;
}
}

return $elements;
}

/**
Expand Down

0 comments on commit 71b1136

Please sign in to comment.