Commit dbd0ee55 authored by MBoretto's avatar MBoretto

fix for inline keyboard

parent a29336e7
......@@ -29,6 +29,71 @@ class Entity
return $json;
}
public function reflect($object = null)
{
if ($object == null) {
$object = $this;
}
$reflection = new \ReflectionObject($object);
$properties = $reflection->getProperties();
$fields = [];
foreach ($properties as $property) {
$name = $property->getName();
if ($name == 'bot_name') {
continue;
}
if (!$property->isPrivate()) {
$array_of_obj = false;
$array_of_array_obj = false;
if (is_array($object->$name)) {
$array_of_obj = true;
$array_of_array_obj = true;
foreach ($object->$name as $elm) {
if (!is_object($elm)) {
//echo $name . " not array of object \n";
$array_of_obj = false;
//break;
}
if (is_array($elm)) {
foreach ($elm as $more_net) {
if (!is_object($more_net)) {
$array_of_array_obj = false;
}
}
}
}
}
if (is_object($object->$name)) {
$fields[$name] = $this->reflect($object->$name);
} elseif ($array_of_obj) {
foreach ($object->$name as $elm) {
$fields[$name][] = $this->reflect($elm);
}
} elseif ($array_of_array_obj) {
foreach ($object->$name as $elm) {
$temp = null;
foreach ($elm as $obj) {
$temp[] = $this->reflect($obj);
}
$fields[$name][] = $temp;
}
} else {
$property->setAccessible(true);
$value = $property->getValue($object);
if (is_null($value)) {
continue;
}
$fields[$name] = $value;
}
}
}
return $fields;
}
public function reflect($object = null)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment