Static constructor.

@param string  $className
@param mixed[] $id

@return self
501009
public static function fromClassNameAndIdentifier($className, array $id)
    {
        $ids = [];

        foreach ($id as $key => $value) {
            $ids[] = $key . '(' . $value . ')';
        }

        return new self(
            'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found'
        );
    }
1365320
public static function findById($className, $id, array $options): ResultInterface
    {
        list($tableName, , $columnId) = self::getTable($className);
        $instance = self::getInstance($className);

        $query = Query::table($tableName)->className($className)->where($columnId, $id)->selectInstance($instance)->addDecorator(function ($result) {
            if (isset($result[0])) {
                return $result[0];
            }

            return null;
        });

        $options['limit'] = 1;
        $query            = self::applyOptions($query, $options);
        $fields           = self::getFieldsFromOptions($options);

        return $query->get($fields);
    }
557996
public static function getInstance($id = 'default')
    {
        if (!isset(static::$instances[$id])) {
            static::$instances[$id] = new self();
        }
        
        return static::$instances[$id];
    }
1212843
public function add($className)
    {
        if (!is_string($className)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($className) ? get_class($className) : gettype($className))));
        }

        $this->parseClassAttribute();

        if (in_array($className, $this->classes, true)) {
            return $this;
        }

        $this->classes[] = $className;

        $this->updateClassAttribute();

        return $this;
    }
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;
    }
1320788
public static function instantiate($className)
    {
        $objectManager = self::get()->getObjectManager();
        $args = func_get_args();

        if (1 === count($args)) {
            return $objectManager->get($className);
        }

        return call_user_func_array([$objectManager, 'get'], $args);
    }
919473
public static function factory($id)
    {
        $id = (string)$id;
        if (!isset(static::$resources[$id])) {
            static::$resources[$id] = new static($id);
        }
        return static::$resources[$id];
    }
511596
public function createModel($class, $id)
    {
        $this->model = new $class();

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

        return $this;
    }
1014575
private function load($id = null)
    {

        $this->initialize();
        $this->id = $id;
        return $this->getDataConnector()->loadContext($this);

    }
1251249
public static function fromClass($className)
    {
        return new self(
            \Pheasant::instance()->schema($className),
            \Pheasant::instance()->finderFor($className)
        );
    }
713045
public static function field($name, $id = null)
    {
        return self::getInstance()
                     ->getBuilder(FieldBehavior::class)
                     ->field($name)
                     ->id($id);
    }
517869
public function instantiateClass(string $className, array $args)
    {
        $class = $this->getClass($className);
        $constructor = $class->getConstructor();
        if (empty($constructor)) {
            $instance = $class->newInstanceWithoutConstructor();
        } else {
            $instance = $class->newInstanceArgs($args);
        }
        return $instance;
    }
1194860
public function singleton($className) {
        $closure = function(ContainerInterface $container) use($className) {
            static $instance;
            
            if (is_null($instance)) {
                $instance = $container->make($className);
            }

            return $instance;
        };

        $this->bind($className, $closure);
    }
983602
public static function find($id, $columns = array('*'))
	{
		if (is_array($id) && empty($id)) return new Collection;

		$instance = new static;

		return $instance->newQuery()->find($id, $columns);
	}
108939
public function setId($id)
    {
        $id = $this->buildId($id);

        if ($this->isRelation($id)) {
            $relations = explode('.', $id);

            $lastElement = array_pop($relations);

            if (!$this->keepOriginalID) {
                $id = $lastElement;
            }

            $this->relations = $relations;
        }

        $this->id = $id;

        return $this;
    }
1329477
public static function getInstance($id)
	{
		static $locales=array();
		if(isset($locales[$id]))
			return $locales[$id];
		else
			return $locales[$id]=new CLocale($id);
	}
322754
public function findById($className, $id)
    {
        return $this->factory->createTransaction()->findByReference(new Reference($className, $id));
    }