public function setupClassInfo($fields = [], $kwargs = [])
    {
//        if (ArrayHelper::hasKey($kwargs, 'registry')) {
//            $registry = $kwargs['registry'];
//        } else {
//            $registry = BaseOrm::getRegistry(false);
//        }

        try {
            $registry = ArrayHelper::getValue($kwargs, 'registry',
                ArrayHelper::STRICT);
        } catch (KeyError $e) {
            throw new InvalidArgumentException('registry not provided');
        }

        // if the registry is already ready and an
        // instance of this class has already been registered with the registry
        // there is no need to register again, just re-use the meta
        // information of the already registered instance
        // remember meta only holds information that related to the
        // class as a whole and not the instances.
        if ($registry->hasModel(get_class($this)) && $registry->ready) {
            $this->loadMeta($registry);
        } else {
            // get meta settings for this model

            $metaSettings = Tools::getClassMetaSettings($this);
            $metaSettings['registry'] = $registry;

            if ($kwargs) {
                if (ArrayHelper::hasKey($kwargs, 'meta')) {
                    $metaSettings = array_merge($kwargs['meta'], $metaSettings);
                }
            }

            $meta = Meta::createObject($metaSettings);

            $this->addToClass('meta', $meta);

            /** @var $immediateParent ReflectionObject */
            list(
                $concreteParentName, $immediateParent,
                $classFields, $parentLink
                ) = self::getHierarchyMeta($this);

            $this->setupFields($fields, $classFields);

            // proxy model setup
            /* @var $concreteParent Model */
            if ($this->getMeta()->proxy) {
                $concreteParentName = Tools::unifyModelName($concreteParentName);
                $concreteParent = $this->getMeta()->getRegistry()
                    ->getRegisteredModel($concreteParentName);
                $this->proxySetup($concreteParent);
            } else {
                $this->getMeta()->setConcreteModel($this);

                // setup for multiple inheritance
                if ($parentLink) {
                    $this->getMeta()->setParentLinks($parentLink);
                }
            }

            // ensure the model is ready for use.
            $this->prepare();

            // register the model
            $meta->getRegistry()->registerModel($this);
        }
    }
public function setupClassInfo($fields = [], $kwargs = [])
    {
//        if (ArrayHelper::hasKey($kwargs, 'registry')) {
//            $registry = $kwargs['registry'];
//        } else {
//            $registry = BaseOrm::getRegistry(false);
//        }

        try {
            $registry = ArrayHelper::getValue($kwargs, 'registry',
                ArrayHelper::STRICT);
        } catch (KeyError $e) {
            throw new InvalidArgumentException('registry not provided');
        }

        // if the registry is already ready and an
        // instance of this class has already been registered with the registry
        // there is no need to register again, just re-use the meta
        // information of the already registered instance
        // remember meta only holds information that related to the
        // class as a whole and not the instances.
        if ($registry->hasModel(get_class($this)) && $registry->ready) {
            $this->loadMeta($registry);
        } else {
            // get meta settings for this model

            $metaSettings = Tools::getClassMetaSettings($this);
            $metaSettings['registry'] = $registry;

            if ($kwargs) {
                if (ArrayHelper::hasKey($kwargs, 'meta')) {
                    $metaSettings = array_merge($kwargs['meta'], $metaSettings);
                }
            }

            $meta = Meta::createObject($metaSettings);

            $this->addToClass('meta', $meta);

            /** @var $immediateParent ReflectionObject */
            list(
                $concreteParentName, $immediateParent,
                $classFields, $parentLink
                ) = self::getHierarchyMeta($this);

            $this->setupFields($fields, $classFields);

            // proxy model setup
            /* @var $concreteParent Model */
            if ($this->getMeta()->proxy) {
                $concreteParentName = Tools::unifyModelName($concreteParentName);
                $concreteParent = $this->getMeta()->getRegistry()
                    ->getRegisteredModel($concreteParentName);
                $this->proxySetup($concreteParent);
            } else {
                $this->getMeta()->setConcreteModel($this);

                // setup for multiple inheritance
                if ($parentLink) {
                    $this->getMeta()->setParentLinks($parentLink);
                }
            }

            // ensure the model is ready for use.
            $this->prepare();

            // register the model
            $meta->getRegistry()->registerModel($this);
        }
    }
public function setupClassInfo ( $ fields = [ ] , $ kwargs = [ ] ) { //        if (ArrayHelper::hasKey($kwargs, 'registry')) { //            $registry = $kwargs['registry']; //        } else { //            $registry = BaseOrm::getRegistry(false); //        } try { $ registry = ArrayHelper :: getValue ( $ kwargs , 'registry' , ArrayHelper :: STRICT ) ; } catch ( KeyError $ e ) { throw new InvalidArgumentException ( 'registry not provided' ) ; } // if the registry is already ready and an // instance of this class has already been registered with the registry // there is no need to register again, just re-use the meta // information of the already registered instance // remember meta only holds information that related to the // class as a whole and not the instances. if ( $ registry -> hasModel ( get_class ( $ this ) ) && $ registry -> ready ) { $ this -> loadMeta ( $ registry ) ; } else { // get meta settings for this model $ metaSettings = Tools :: getClassMetaSettings ( $ this ) ; $ metaSettings [ 'registry' ] = $ registry ; if ( $ kwargs ) { if ( ArrayHelper :: hasKey ( $ kwargs , 'meta' ) ) { $ metaSettings = array_merge ( $ kwargs [ 'meta' ] , $ metaSettings ) ; } } $ meta = Meta :: createObject ( $ metaSettings ) ; $ this -> addToClass ( 'meta' , $ meta ) ; /** @var $immediateParent ReflectionObject */ list ( $ concreteParentName , $ immediateParent , $ classFields , $ parentLink ) = self :: getHierarchyMeta ( $ this ) ; $ this -> setupFields ( $ fields , $ classFields ) ; // proxy model setup /* @var $concreteParent Model */ if ( $ this -> getMeta ( ) -> proxy ) { $ concreteParentName = Tools :: unifyModelName ( $ concreteParentName ) ; $ concreteParent = $ this -> getMeta ( ) -> getRegistry ( ) -> getRegisteredModel ( $ concreteParentName ) ; $ this -> proxySetup ( $ concreteParent ) ; } else { $ this -> getMeta ( ) -> setConcreteModel ( $ this ) ; // setup for multiple inheritance if ( $ parentLink ) { $ this -> getMeta ( ) -> setParentLinks ( $ parentLink ) ; } } // ensure the model is ready for use. $ this -> prepare ( ) ; // register the model $ meta -> getRegistry ( ) -> registerModel ( $ this ) ; } }
This method is for internal use only and should not be overriden.

@ignore

@internal

@param array $fields
@param array $kwargs

@throws FieldError
@throws InvalidArgumentException
@throws KeyError
@throws LookupError
@throws MethodNotExtendableException
@throws TypeError
@throws \Eddmash\PowerOrm\Exception\ImproperlyConfigured
@author: Eddilbert Macharia (http://eddmash.com)<edd.cowan@gmail.com>
This method is for internal use only and should not be overriden .