@param string      $modelClass
@param string|null $id

@return ModelInterface|null
351224
public function find(string $modelClass, string $id = null)
    {
        if (null === $id) {
            return null;
        }

        return $this->getRepositoryByClass($modelClass)->find($id);
    }
247464
protected function findModel($modelClass, $attributes = [])
    {
        $query = $this->buildQuery($modelClass, $attributes);

        return $query->first();
    }
866054
private function getActiveModel(ModelIdInterface $modelId)
    {
        if (!Database::getInstance()->tableExists($modelId->getDataProviderName())) {
            return null;
        }
        $dataProvider = $this->itemContainer->getEnvironment()->getDataProvider();

        return $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId()));
    }
1034907
private function getEntity($id, $entityClass = null)
    {
        if (empty($entityClass)) {
            $entityClass = $this->entityClass;
        }

        $entity = $this->getEntityManager()->find($entityClass, $id);

        if (empty($entity)) {
            throw $this->createNotFoundException(
                sprintf('Unable to find entity "%s" by ID "%d".', $entityClass, $id)
            );
        }

        return $entity;
    }
908250
public function createMany(array $data, $modelClass = null)
    {
        $models = [];
        foreach ($data as $item) {
            $models[] = $this->fromArray($item, $modelClass);
        }

        return $models;
    }
1210016
public function setClass($id, $class)
    {
        $this->classes[$id] = $class;
        if (isset($this->items[$id])) {
            unset($this->items[$id]);
        }
        $this->allCreated = false;
        return $this;
    }
267814
public function fetchFirstObj(string $class = null): ?object
    {
        if ($class == null && $this->modelClass !== null) {
            return parent::fetchFirstObj($this->modelClass);
        } else {
            return parent::fetchFirstObj($class);
        }
    }
186222
public function findOneBy(string $modelClass, array $criteria, array $orderBy = null)
    {
        return $this->getRepositoryByClass($modelClass)->findOneBy($criteria, $orderBy);
    }
1042936
protected function getPluginClass($id)
    {
        return isset($this->pluginClasses[$id]) ? $this->pluginClasses[$id] : null;
    }
341996
public <T> T getModel(Class<T> modelClass) {
		return (T)Injector.injectModel(modelClass, request, false);
	}
1070197
protected function setId(Identifier $id, Model $model): void
    {
        $prop = new ReflectionProperty(get_class($model), 'id');
        $prop->setAccessible(true);
        $prop->setValue($model, $id);
    }
926451
static function factory($model, $id = null) {
        if (is_string($model)) {
            $model_class = $model;
            if($model_class::isSoftDelete()){
                $model       = $model_class::withTrashed()->find($id);
            } else {
                $model       = $model_class::find($id);
            }
        }
        else {
            $model_class = get_class($model);
        }
        $acl_class = str_replace('\Model\\', '\Acl\Acl', \Str::studly($model_class));
        if (!class_exists($acl_class)) {
            $acl_class = __CLASS__;
        }
        return new $acl_class($model);
    }
1125262
public function findById($class, $id) {
        $mapper = MapperBuilder::buildFromMapping($this->mapping, $class);

        $newEntity = NULL;

        $query = "SELECT * FROM `" . $mapper->getTable() . "` WHERE id='$id'";
        $result = $this->conn->executeQuery($query);

        if ($result) {
            $class = $mapper->getClass();
            $newEntity = new $class();
            $this->populateEntity($newEntity, $result[0], $mapper);

            // populate relations
            foreach ($mapper->getRelations() as $relation) {

                $relMapper = MapperBuilder::buildFromName($this->mapping, $relation->getEntity());
                $queryRel = $this->buildSelectRelation($newEntity, $mapper, $relation, $relMapper);
                $resRel = $this->conn->executeQuery($queryRel);

                $classRel = $relMapper->getClass();
                $method = "set" . $relation->getName();
                if ($resRel) {
                    foreach ($resRel as $row) {
                        $newEntityRel = new $classRel();
                        $this->populateEntity($newEntityRel, $row, $relMapper, $relation->getForeignColumn());
                        $array[] = $newEntityRel;
                    }
                    $newEntity->$method($array);
                }
            }
        }
        return $newEntity;
    }
1180333
public function setModel(ModelInterface $model = null): ModelReferenceInterface
    {
        $this->resolveModel();

        $this->model = $model;
        $this->id = null !== $model ? $model->getId() : null;

        return $this;
    }
483029
public function getAction(Request $request, $id, $class)
    {
        $query = $request->query->all();
        $object = $this->find($class, $id);

        $options = $this->options['get'];

        if (isset($query['options'])) {
            $options = $query['options'];
        }

        return $object ?
            new JsonResponse(
                $this->serializer->serialize($object, $options)
            ) :
            new JsonResponse("No object found for id {$id} of class {$class}", 404);
    }
511596
public function createModel($class, $id)
    {
        $this->model = new $class();

        if ($id) {
            $this->model->setId($id);
        }

        return $this;
    }
1369082
public function findModelClassObject($modelClass, $id, $relationContext)
    {
        $keys = $modelClass::primaryKey();
        if (count($keys) > 1) {
            $values = explode(',', $id);
            if (count($keys) === count($values)) {
                return $this->findModelFromCondition(array_combine($keys, $values), $keys, $modelClass, $relationContext);
            }
        } elseif ($id !== null) {
            return $this->findModelFromCondition($id, $keys, $modelClass, $relationContext);
        }

        return false;
    }