diff --git a/app/Tygh/Api.php b/app/Tygh/Api.php index 9457cdc..9ba6b97 100644 --- a/app/Tygh/Api.php +++ b/app/Tygh/Api.php @@ -500,14 +500,18 @@ class Api */ protected function getObjectByEntity($entity_properties) { - $version_namespace = ''; - if ($this->called_version != self::CURRENT_VERSION) { - $version_namespace = 'v' . str_replace('.', '', $this->called_version) . '\\'; - } - $class_name = "\\Tygh\\Api\\Entities\\" . $version_namespace . fn_camelize($entity_properties['name']); + $version = ($this->called_version == self::CURRENT_VERSION ? '' : 'v' . str_replace('.', '', $this->called_version) . '\\'); + $class_name = "\\Tygh\\Api\\Entities\\" . $version . fn_camelize($entity_properties['name']); $entity = class_exists($class_name) ? new $class_name($this->auth, $this->area) : null; + if (!$entity) { + $class_name = "\\Tygh\\Api\\Entities\\" . fn_camelize($entity_properties['name']); + if (class_exists($class_name)) { + $entity = new $class_name($this->auth, $this->area); + } + } + return $entity; }