Pimcore\Tool\RestClient::getObjectById PHP Метод

getObjectById() публичный Метод

public getObjectById ( $id, $decode = true, $idMapper = null )
    public function getObjectById($id, $decode = true, $idMapper = null)
    {
        $url = $this->buildEndpointUrl("object/id/" . $id);
        if ($this->getEnableProfiling()) {
            $this->profilingInfo = null;
            $url .= "&profiling=1";
        }
        if ($this->getCondense()) {
            $url .= "&condense=1";
        }
        $response = $this->doRequest($url, "GET");
        if ($this->getEnableProfiling()) {
            $this->profilingInfo = $response->profiling;
        }
        $response = $response->data;
        $wsDocument = $this->fillWebserviceData("\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In", $response);
        if (!$decode) {
            return $wsDocument;
        }
        if ($wsDocument->type == "folder") {
            $object = new Object\Folder();
            $wsDocument->reverseMap($object);
            return $object;
        } elseif ($wsDocument->type == "object" || $wsDocument->type == "variant") {
            $classname = "Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className);
            $object = \Pimcore::getDiContainer()->make($classname);
            if ($object instanceof Object\Concrete) {
                $curTime = microtime(true);
                $wsDocument->reverseMap($object, $this->getDisableMappingExceptions(), $idMapper);
                $timeConsumed = round(microtime(true) - $curTime, 3) * 1000;
                if ($this->profilingInfo) {
                    $this->profilingInfo->reverse = $timeConsumed;
                }
                return $object;
            } else {
                throw new Exception("Unable to decode object, could not instantiate Object with given class name [ {$classname} ]");
            }
        }
    }