code/libraries/joomlatools/library/model/entity/composite.php
public function create(array $properties = array(), $status = null)
    {
        if($this->_prototypable)
        {
            if(!$this->_prototype instanceof KModelEntityInterface)
            {
                $identifier = $this->getIdentifier()->toArray();
                $identifier['path'] = array('model', 'entity');
                $identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);

                //The entity default options
                $options = array(
                    'identity_key' => $this->getIdentityKey()
                );

                $this->_prototype = $this->getObject($identifier, $options);
            }

            $entity = clone $this->_prototype;

            $entity->setStatus($status);
            $entity->setProperties($properties, $entity->isNew());
        }
        else
        {
            $identifier = $this->getIdentifier()->toArray();
            $identifier['path'] = array('model', 'entity');
            $identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);

            //The entity default options
            $options = array(
                'data'         => $properties,
                'status'       => $status,
                'identity_key' => $this->getIdentityKey()
            );

            $entity = $this->getObject($identifier, $options);
        }

        //Insert the entity into the collection
        $this->insert($entity);

        return $entity;
    }
public function create(array $properties = array(), $status = null)
    {
        if($this->_prototypable)
        {
            if(!$this->_prototype instanceof KModelEntityInterface)
            {
                $identifier = $this->getIdentifier()->toArray();
                $identifier['path'] = array('model', 'entity');
                $identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);

                //The entity default options
                $options = array(
                    'identity_key' => $this->getIdentityKey()
                );

                $this->_prototype = $this->getObject($identifier, $options);
            }

            $entity = clone $this->_prototype;

            $entity->setStatus($status);
            $entity->setProperties($properties, $entity->isNew());
        }
        else
        {
            $identifier = $this->getIdentifier()->toArray();
            $identifier['path'] = array('model', 'entity');
            $identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);

            //The entity default options
            $options = array(
                'data'         => $properties,
                'status'       => $status,
                'identity_key' => $this->getIdentityKey()
            );

            $entity = $this->getObject($identifier, $options);
        }

        //Insert the entity into the collection
        $this->insert($entity);

        return $entity;
    }
public function create ( array $ properties = array ( ) , $ status = null ) { if ( $ this -> _prototypable ) { if ( ! $ this -> _prototype instanceof KModelEntityInterface ) { $ identifier = $ this -> getIdentifier ( ) -> toArray ( ) ; $ identifier [ 'path' ] = array ( 'model' , 'entity' ) ; $ identifier [ 'name' ] = KStringInflector :: singularize ( $ this -> getIdentifier ( ) -> name ) ; //The entity default options $ options = array ( 'identity_key' => $ this -> getIdentityKey ( ) ) ; $ this -> _prototype = $ this -> getObject ( $ identifier , $ options ) ; } $ entity = clone $ this -> _prototype ; $ entity -> setStatus ( $ status ) ; $ entity -> setProperties ( $ properties , $ entity -> isNew ( ) ) ; } else { $ identifier = $ this -> getIdentifier ( ) -> toArray ( ) ; $ identifier [ 'path' ] = array ( 'model' , 'entity' ) ; $ identifier [ 'name' ] = KStringInflector :: singularize ( $ this -> getIdentifier ( ) -> name ) ; //The entity default options $ options = array ( 'data' => $ properties , 'status' => $ status , 'identity_key' => $ this -> getIdentityKey ( ) ) ; $ entity = $ this -> getObject ( $ identifier , $ options ) ; } //Insert the entity into the collection $ this -> insert ( $ entity ) ; return $ entity ; }
Create a new entity and insert it

This function will either clone the entity object, or create a new instance of the entity object for each entity
being inserted. By default the entity will be cloned.

@param   array   $properties The entity properties
@param   string  $status     The entity status
@return  KModelEntityComposite
Create a new entity and insert it