Get object by id

@param string $classname
@param int $id
@return AbstractModel
760251
public function getById($classname, $id)
    {
        if (!preg_match('/^[0-9]+$/D', $id)) {
            throw new InvalidIdException('Invalid id: ' . $id);
        }
        $response = $this->request($this->buildUrl(new $classname(array('id' => $id))), 'GET');
        return $this->mapper->mapFromStorage($response);
    }
780975
private function getCachedDataByClassNameAndId($className, $id)
    {
        if (!array_key_exists($className, $this->cache)) {
            throw new CacheMissException();
        }

        if (!array_key_exists($id, $this->cache[$className])) {
            throw new CacheMissException();
        }

        return $this->cache[$className][$id];
    }
936594
public static function get($id)
    {
        /** @var Entity $entity */
        $entity = new static();
        Manager::getInstance()->get($entity)->refreshRelations();
        $className = $entity->getClassName();
        $sql = Sql::createSql($entity->getAdapter())
            ->select($entity->getTableName())
            ->where(
                [
                    "{$entity->getTableName()}.{$entity->_primaryKey} = :id" =>
                        [
                            ':id' => $id
                        ]
                ]
            );
        $events = $entity->getEventManager();
        $event = new Select([
            'sqlQuery' => $sql,
            'params' => compact('id'),
            'action' => Select::GET,
            'singleItem' => true
        ]);
        $events->trigger(Select::BEFORE_SELECT, $entity, $event);
        $row = $event->sqlQuery->first();

        if ($row) {
            $event->data = $row;
            $events->trigger(Select::AFTER_SELECT, $entity, $event);
            $object = new $className($event->data);
            return $object;
        }
        return null;
    }
844288
public static function deleteById($className, $id): ResultInterface
    {
        list($table, , $idColumn) = self::getTable($className);
        $instance = self::getInstance($className);

        $query = Query::table($table)->where($idColumn, $id)->selectInstance($instance);

        return $query->delete();
    }
162543
protected function loadModel($id = null)
	{
		/** @var BaseActiveRecord $modelClass */
		$modelClass = $this->modelClass();
		if($id) {
			$this->modelInstance = $modelClass::findOne($id);
		} else {
			$this->modelInstance = new $modelClass();
		}
		$this->modelInstance->load($this->attributes, '');
		return $this->modelInstance;
	}
1276395
public function get($id)
    {
        if (!$this->has($id)) {
            return;
        }

        return $this->container->findDefinition($id)->getClass();
    }
349907
public function handlerIdByClassName($className)
    {
        foreach ($this->handlers() as $id => $class) {
            if ($class->className() === $className) {
                return $id;
            }
        }

        throw new Exception("Handler with classname {$className} not found.");
    }
1301347
protected function getReflectionById($id) {
		if (! isset($this->classReflections[$id])) {
			$this->classReflections[$id] = $this->initReflection($id);
		}
		
		return $this->classReflections[$id];
	}
492209
public static function get_by_object_classname($classname) {
		$db = Database::Get();
		$ids = $db->getCol('SELECT id FROM object_text WHERE classname=?', [ $classname ]);
		$object_texts = [];
		foreach ($ids as $id) {
			$object_texts[] = self::get_by_id($id);
		}
		return $object_texts;
	}
918694
public function getById($id)
    {
        $id = (int) $id;
        $rowSet = $this->getTableGateway()->select([$this->getPrimaryKey() => $id]);
        $row = $rowSet->current();
        return $row;
    }
511062
public function get($id)
    {
        if ($this->has($id) === false) {
            throw NotFoundException::classDoesNotExist($id);
        }

        try {
            return $this->injector->make($id);
        } catch (InjectorException $e) {
            throw ContainerException::couldNotMake($id, $e);
        }
    }
418483
public static function storageIdByClass($className)
    {
        foreach (self::storageHandlers() as $id => $handler) {
            if ($handler instanceof $className) {
                return $id;
            }
        }
        return null;
    }
446960
public function getByNamedId($classname, $name, $id)
    {
        if (!isset($this->namedId[$classname]) || !in_array($name, $this->namedId[$classname])) {
            throw new InvalidNamedIdExeption('NamedId ' . $name . ' is not a valid type');
        }
        if (!preg_match('/^[a-zA-Z0-9\- _]+$/D', $id)) {
            throw new InvalidIdException('Invalid id: ' . $id);
        }
        $response = $this->request($this->buildUrl(new $classname(), null, '/' . $name . '/' . $id), 'GET');
        return $this->mapper->mapFromStorage($response);
    }
1107000
public function getById($id)
    {
        if ($this->id == $id) return $this;

        return $this->children->getById($id);
    }
1116283
public function getById(int $id, string $forClassName)
    {
        $params    = $this->getQueryParams();
        $type      = CorrelationTypeHelper::getGraphTypeByClass($forClassName);
        $uriAppend = "{$type}/{$id}";

        unset($params['limit'], $params['offset']);

        $response = $this->handler->handle('GET', false, $uriAppend, $params)->getData();
        if (!$response) {
            return [];
        }

        $functionalNames = [];
        if ($filter = $this->getFilter()) {
            $functionalNames = current($filter->getElements())['functionalNames'] ?? null;
        }

        return $this->client->elastic()
                            ->search($this->prepareElasticSearchBody($response, ['functionalNameId' => $functionalNames]))
                            ->all();
    }
1325397
public function fetchById($id)
    {
        $data = $this->getProvider()->fetchById($id);
        return $this->resultAsModel($data);
    }
1269705
public function get($id)
	{
		$this->getResponse()
			->setStatusCode(Response::STATUS_CODE_200);
		
		$classifiedService = $this->getServiceLocator()->get('document.service.classified');
		
		try {
			$data = $classifiedService->get($id);
		} catch(\Exception $e) {
			$this->getResponse()
				->setStatusCode(Response::STATUS_CODE_500);
			$data = new \StdClass();
		}
		
		return new JsonModel(array(
			'data' => $data
		));
	}