Skip to content

Commit dbd0ee5

Browse files
committed
fix for inline keyboard
1 parent a29336e commit dbd0ee5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/Entities/Entity.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,71 @@ public function toJson()
2929
return $json;
3030
}
3131

32+
public function reflect($object = null)
33+
{
34+
if ($object == null) {
35+
$object = $this;
36+
}
37+
38+
$reflection = new \ReflectionObject($object);
39+
$properties = $reflection->getProperties();
40+
41+
$fields = [];
42+
43+
foreach ($properties as $property) {
44+
$name = $property->getName();
45+
if ($name == 'bot_name') {
46+
continue;
47+
}
48+
49+
if (!$property->isPrivate()) {
50+
$array_of_obj = false;
51+
$array_of_array_obj = false;
52+
if (is_array($object->$name)) {
53+
$array_of_obj = true;
54+
$array_of_array_obj = true;
55+
foreach ($object->$name as $elm) {
56+
if (!is_object($elm)) {
57+
//echo $name . " not array of object \n";
58+
$array_of_obj = false;
59+
//break;
60+
}
61+
if (is_array($elm)) {
62+
foreach ($elm as $more_net) {
63+
if (!is_object($more_net)) {
64+
$array_of_array_obj = false;
65+
}
66+
}
67+
}
68+
}
69+
}
70+
71+
if (is_object($object->$name)) {
72+
$fields[$name] = $this->reflect($object->$name);
73+
} elseif ($array_of_obj) {
74+
foreach ($object->$name as $elm) {
75+
$fields[$name][] = $this->reflect($elm);
76+
}
77+
} elseif ($array_of_array_obj) {
78+
foreach ($object->$name as $elm) {
79+
$temp = null;
80+
foreach ($elm as $obj) {
81+
$temp[] = $this->reflect($obj);
82+
}
83+
$fields[$name][] = $temp;
84+
}
85+
} else {
86+
$property->setAccessible(true);
87+
$value = $property->getValue($object);
88+
if (is_null($value)) {
89+
continue;
90+
}
91+
$fields[$name] = $value;
92+
}
93+
}
94+
}
95+
return $fields;
96+
}
3297

3398
public function reflect($object = null)
3499
{

0 commit comments

Comments
 (0)