public function execute()
    {
        $entity = $this->aggregate->getEntityObject();
        $wrappedEntity = $this->aggregate->getWrappedEntity();
        $mapper = $this->aggregate->getMapper();

        if ($mapper->fireEvent('storing', $wrappedEntity) === false) {
            return false;
        }

        $this->preStoreProcess();

        /*
         * We will test the entity for existence
         * and run a creation if it doesn't exists
         */
        if (!$this->aggregate->exists()) {
            if ($mapper->fireEvent('creating', $wrappedEntity) === false) {
                return false;
            }

            $this->insert();

            $mapper->fireEvent('created', $wrappedEntity, false);
        } elseif ($this->aggregate->isDirty()) {
            if ($mapper->fireEvent('updating', $wrappedEntity) === false) {
                return false;
            }
            $this->update();

            $mapper->fireEvent('updated', $wrappedEntity, false);
        }

        $this->postStoreProcess();

        $mapper->fireEvent('stored', $wrappedEntity, false);

        // Once the object is stored, add it to the Instance cache
        $key = $this->aggregate->getEntityKeyValue();

        if (!$mapper->getInstanceCache()->has($key)) {
            $mapper->getInstanceCache()->add($entity, $key);
        }

        $this->syncForeignKeyAttributes();

        $wrappedEntity->unwrap();

        return $entity;
    }
public function execute()
    {
        $entity = $this->aggregate->getEntityObject();
        $wrappedEntity = $this->aggregate->getWrappedEntity();
        $mapper = $this->aggregate->getMapper();

        if ($mapper->fireEvent('storing', $wrappedEntity) === false) {
            return false;
        }

        $this->preStoreProcess();

        /*
         * We will test the entity for existence
         * and run a creation if it doesn't exists
         */
        if (!$this->aggregate->exists()) {
            if ($mapper->fireEvent('creating', $wrappedEntity) === false) {
                return false;
            }

            $this->insert();

            $mapper->fireEvent('created', $wrappedEntity, false);
        } elseif ($this->aggregate->isDirty()) {
            if ($mapper->fireEvent('updating', $wrappedEntity) === false) {
                return false;
            }
            $this->update();

            $mapper->fireEvent('updated', $wrappedEntity, false);
        }

        $this->postStoreProcess();

        $mapper->fireEvent('stored', $wrappedEntity, false);

        // Once the object is stored, add it to the Instance cache
        $key = $this->aggregate->getEntityKeyValue();

        if (!$mapper->getInstanceCache()->has($key)) {
            $mapper->getInstanceCache()->add($entity, $key);
        }

        $this->syncForeignKeyAttributes();

        $wrappedEntity->unwrap();

        return $entity;
    }
public function execute ( ) { $ entity = $ this -> aggregate -> getEntityObject ( ) ; $ wrappedEntity = $ this -> aggregate -> getWrappedEntity ( ) ; $ mapper = $ this -> aggregate -> getMapper ( ) ; if ( $ mapper -> fireEvent ( 'storing' , $ wrappedEntity ) === false ) { return false ; } $ this -> preStoreProcess ( ) ; /*
         * We will test the entity for existence
         * and run a creation if it doesn't exists
         */ if ( ! $ this -> aggregate -> exists ( ) ) { if ( $ mapper -> fireEvent ( 'creating' , $ wrappedEntity ) === false ) { return false ; } $ this -> insert ( ) ; $ mapper -> fireEvent ( 'created' , $ wrappedEntity , false ) ; } elseif ( $ this -> aggregate -> isDirty ( ) ) { if ( $ mapper -> fireEvent ( 'updating' , $ wrappedEntity ) === false ) { return false ; } $ this -> update ( ) ; $ mapper -> fireEvent ( 'updated' , $ wrappedEntity , false ) ; } $ this -> postStoreProcess ( ) ; $ mapper -> fireEvent ( 'stored' , $ wrappedEntity , false ) ; // Once the object is stored, add it to the Instance cache $ key = $ this -> aggregate -> getEntityKeyValue ( ) ; if ( ! $ mapper -> getInstanceCache ( ) -> has ( $ key ) ) { $ mapper -> getInstanceCache ( ) -> add ( $ entity , $ key ) ; } $ this -> syncForeignKeyAttributes ( ) ; $ wrappedEntity -> unwrap ( ) ; return $ entity ; }
Persist the entity in the database.

@throws \InvalidArgumentException

@return false|mixed
Persist the entity in the database .