public function getEntity($config = array())
    {
        if ($this->getDescription()->isAbstract()) {
            throw new AnDomainRepositoryException('Can not instantiate an abstract entity '.$this->getDescription()->getEntityIdentifier());
        }

        $context = $this->getCommandContext();
        $context->append(array('data' => array()));
        $context->append($config);

        //force data to be stored by real name
        foreach ($context->data as $key => $value) {
            $property = $this->getDescription()->getProperty($key);
            if ($property) {
                unset($context->data[$key]);
                $context->data[$property->getName()] = $value;
            }
        }

        $entity = clone $this->getClone();
        $context->entity = $entity;
        $this->getCommandChain()->run('after.instantiate', $context);

        //set the entity data
        $data = AnConfig::unbox($context['data']);
        $entity->setData($data, AnDomain::ACCESS_PROTECTED);

        return $entity;
    }
public function getEntity($config = array())
    {
        if ($this->getDescription()->isAbstract()) {
            throw new AnDomainRepositoryException('Can not instantiate an abstract entity '.$this->getDescription()->getEntityIdentifier());
        }

        $context = $this->getCommandContext();
        $context->append(array('data' => array()));
        $context->append($config);

        //force data to be stored by real name
        foreach ($context->data as $key => $value) {
            $property = $this->getDescription()->getProperty($key);
            if ($property) {
                unset($context->data[$key]);
                $context->data[$property->getName()] = $value;
            }
        }

        $entity = clone $this->getClone();
        $context->entity = $entity;
        $this->getCommandChain()->run('after.instantiate', $context);

        //set the entity data
        $data = AnConfig::unbox($context['data']);
        $entity->setData($data, AnDomain::ACCESS_PROTECTED);

        return $entity;
    }
public function getEntity ( $ config = array ( ) ) { if ( $ this -> getDescription ( ) -> isAbstract ( ) ) { throw new AnDomainRepositoryException ( 'Can not instantiate an abstract entity ' . $ this -> getDescription ( ) -> getEntityIdentifier ( ) ) ; } $ context = $ this -> getCommandContext ( ) ; $ context -> append ( array ( 'data' => array ( ) ) ) ; $ context -> append ( $ config ) ; //force data to be stored by real name foreach ( $ context -> data as $ key => $ value ) { $ property = $ this -> getDescription ( ) -> getProperty ( $ key ) ; if ( $ property ) { unset ( $ context -> data [ $ key ] ) ; $ context -> data [ $ property -> getName ( ) ] = $ value ; } } $ entity = clone $ this -> getClone ( ) ; $ context -> entity = $ entity ; $ this -> getCommandChain ( ) -> run ( 'after.instantiate' , $ context ) ; //set the entity data $ data = AnConfig :: unbox ( $ context [ 'data' ] ) ; $ entity -> setData ( $ data , AnDomain :: ACCESS_PROTECTED ) ; return $ entity ; }
Return a new entity initialized with the new properties.

@param array $config An array of configuration for the entity

@return AnDomainEntityAbstract
Return a new entity initialized with the new properties .