@param string $className
@param array  $data

@return object The model instance.

@throws \RuntimeException
323086
public function createModel($className, $data)
    {
        $model = new $className;

        foreach ($data as $managerName => $value) {
            $is_collection = is_array($value);

            if ($is_collection) {
                $method_name = 'get' . ucfirst($managerName);
            } else {
                $method_name = 'set' . ucfirst($managerName);
            }

            if (!method_exists($model, $method_name)) {
                throw new \RuntimeException(sprintf('Method "%s" does not exist in "%s" class.', $method_name, $className));
            }

            if ($is_collection) {
                foreach ($value as $element) {
                    $model->$method_name()->add($element);
                }
            } else {
                $model->$method_name($value);
            }
        }

        return $model;
    }
671592
public static function of($builder, $classname = null)
    {
        $datatables          = app(Datatables::class);
        $datatables->builder = $builder;
        $engine              = ($builder instanceof QueryBuilder) ? $datatables->usingQueryBuilder($builder) : ($builder instanceof Collection ? $datatables->usingCollection($builder) : $datatables->usingEloquent($builder));
        $engine->setCalledClass($classname);
        return $engine;
    }
1078853
public function instance($classname)
    {
        // Find the class instance, and register the class if the instance is not found.
        if(!($instance = jaxon()->getPluginManager()->getRegisteredObject($classname)))
        {
            $instance = jaxon()->registerClass($classname, [], true);
        }
        if(($instance))
        {
            $this->initInstance($instance);
        }
        return $instance;
    }
636048
public function newInstance($className, array $args = array())
    {

        // load the reflection data for the passed class name
        $reflectionClass = $this->getReflectionClass($className);

        // query whether or not the class has a constructor
        if ($reflectionClass->hasMethod($methodName = '__construct') &&
            $reflectionClass->getMethod($methodName)->getParameters() &&
            sizeof($args) > 0
        ) {
            return $reflectionClass->newInstanceArgs($args);
        }

        // return the instance without calling the constructor
        return $reflectionClass->newInstance();
    }
408505
public function getArray($className = null)
    {
        $this->parseDefer();
        if(!$this->isSuccess)
        {
            throw new \RuntimeException('Result is not success!');
        }
        $result = $this->statement->fetchAll();
        if(false === $result)
        {
            return null;
        }

        if(null === $className)
        {
            $className = $this->modelClass;
        }
        if(null === $className)
        {
            return $result;
        }
        else
        {
            $list = [];
            $isModelClass = is_subclass_of($className, Model::class);
            $supportIEvent = is_subclass_of($className, IEvent::class);
            foreach($result as $item)
            {
                if($isModelClass)
                {
                    $object = BeanFactory::newInstance($className, $item);
                }
                else
                {
                    $object = $item;
                }
                if($supportIEvent)
                {
                    $object->trigger(ModelEvents::AFTER_QUERY, [
                        'model'      =>  $object,
                    ], $object, AfterQueryEventParam::class);
                }
                $list[] = $object;
            }
            return $list;
        }
    }
121489
public static function fromData(array $data)
    {
        $class = get_called_class();
        $isDynamic = is_a($class, DynamicEntity::class, true);

        /** @var static $entity */
        $entity = (new \ReflectionClass($class))->newInstanceWithoutConstructor();

        object_set_properties($entity, $data, $isDynamic);

        if (method_exists($entity, '__construct')) {
            $entity->__construct();
        }

        $entity->markNew(false);

        return $entity;
    }
1252187
private function getEntityFromIdentityMap($className, array $data)
    {
        // TODO: Abstract this code and UnitOfWork::createEntity() equivalent?
        $class = $this->_metadataCache[$className];

        /* @var $class ClassMetadata */
        if ($class->isIdentifierComposite) {
            $idHash = '';

            foreach ($class->identifier as $fieldName) {
                $idHash .= ' ' . (isset($class->associationMappings[$fieldName])
                    ? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
                    : $data[$fieldName]);
            }

            return $this->_uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName);
        } else if (isset($class->associationMappings[$class->identifier[0]])) {
            return $this->_uow->tryGetByIdHash($data[$class->associationMappings[$class->identifier[0]]['joinColumns'][0]['name']], $class->rootEntityName);
        }

        return $this->_uow->tryGetByIdHash($data[$class->identifier[0]], $class->rootEntityName);
    }
1254152
public static function arrayToEntity(array $data, string $className)
    {
        $attrs    = [];
        $object   = new $className();
        $entities = EntityCollector::getCollector();

        foreach ($data as $col => $value) {
            if (!isset($entities[$className]['column'][$col])) {
                continue;
            }

            $field        = $entities[$className]['column'][$col];
            $setterMethod = StringHelper::camel('set_' . $field);

            $type  = $entities[$className]['field'][$field]['type'];
            $value = self::trasferTypes($type, $value);

            if (\method_exists($object, $setterMethod)) {
                $attrs[$field] = $value;
                // 当从数据库取出来的数据不为null时，再进行模型赋值
                if ($value !== null) {
                    $object->$setterMethod($value);
                }
            }
        }
        if (\method_exists($object, 'setAttrs')) {
            $object->setAttrs($attrs);
        }

        return $object;
    }
5831
public function createNew($className)
    {
        $constructArguments = func_get_args();
        $object = $this->_createNew( ...$constructArguments);
        
        $traits = class_uses($object);

        if (isset($traits[Framework::class]) == true) {
            $object->setContainer($this->container);
        }

        return $object;
    }
167948
private static function createObject($className, array $args = null)
    {
        try {
            if (!$args) {
                return new $className;
            } else {
                $c = new \ReflectionClass($className);
                return $c->newInstanceArgs($args);
            }
        } catch (\Exception $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode(), $e);
        }
    }
72887
private function createObject(string $className, array $data)
    {
        $repository = $this->objectManager->getRepository($className);

        $object = $repository->create($className);

        if ($object instanceof NotifyPropertyChanged) {
            $object->addPropertyChangedListener($this);
        }

        $this->eventDispatcher->dispatchPreLoad($object, $data);

        $repository->hydrate($object, $data);

        $this->eventDispatcher->dispatchPostLoad($object);

        $this->objectIdentityMap->addToIdentityMap($object, $data);

        return $object;
    }
315579
public function removeClass($classname)
    {
        $classArr = array_diff($this->getClassArray(), [$classname]);
        return $this->setClassArray($classArr);
    }
156556
public function getNewBuilder(Table $table, $classname)
    {
        /** @var DataModelBuilder $builder */
        $builder = new $classname($table);
        $builder->setGeneratorConfig($this);

        return $builder;
    }
1125366
public static function fromData(array $data)
    {
        $reflection = new \ReflectionClass(static::class);
        $instance = $reflection->newInstanceWithoutConstructor();
        $instance->data = $data;
        $instance->jsonUnserialize($data);
        return $instance;
    }
616987
public function getEntityBuilder($className = null, ClassMetadata $classMetadata = null)
    {
        $builder = new Entity\Builder($this->getMapper(), $this->getFieldManager());

        if ($className !== null) {
            $builder->setClass($className);
        }

        if ($classMetadata !== null) {
            $builder->setClassMetadata($classMetadata);
        }

        return $builder;
    }
503702
private function createDataProviderClass(
        string $providerName,
        array $providerData,
        PhpNamespace $namespace
    ): ClassType {
        $dataProvider = $this->createNewDataProvider($providerName, $namespace);
        $providerElements = $providerData['elements'];

        foreach ($providerElements as $element) {
            $this->addProperty($dataProvider, $element);
            $this->addGetter($dataProvider, $element, $providerData['configs']);
            $this->addSetter($dataProvider, $element, $providerData['configs']);
            $this->addUnsetter($dataProvider, $element, $providerData['configs']);
            $this->addHas($dataProvider, $element, $providerData['configs']);
            $this->addSingleSetter($element, $dataProvider, $providerData['configs']);

        }

        $this->addElementsGetter($dataProvider, $providerElements);
        return $dataProvider;
    }
405715
public static function getClassProfile($classname) {
		if (!is_string($classname) || empty($classname)) {
			throw new \InvalidArgumentException("Argument is not a valid class name");
		}
		
		//check if is already stored
		if (array_key_exists($classname, self::$profiles)) {
			return self::$profiles[$classname];
		}
		
		//validate classname
 		if (!class_exists($classname, true)) {
 			throw new \RuntimeException("Class %s could not be found");
 		}
		
		//build profile and return
		self::$profiles[$classname] = new ClassProfile($classname);
		return self::$profiles[$classname];
	}