public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);
        $result = $context->result;

        //after an action save
        if ($parts[0] === 'after' && $parts[1] != 'cancel') {

            //skip if there are not any commitable
            if (count($this->getRepository()->getSpace()->getCommitables()) == 0) {
                return;
            }

            $result = $this->commit();

            $type = $result === false ? 'error' : 'success';
            $message = $this->_makeStatusMessage($context->action, $type);

            if ($message) {
                $this->setMessage($message, $type);
            }

            if ($result === false) {
                if ($this->isIdentifiable() && $this->getItem()) {
                    if ($this->getItem()->getErrors()->count()) {
                        throw new AnErrorException($this->getItem()->getErrors(), AnHttpResponse::BAD_REQUEST);
                        return;
                    }
                } else {
                    $errors = AnHelperArray::getValues($this->getCommitErrors());
                    throw new AnErrorException($errors, AnHttpResponse::BAD_REQUEST);
                    return;
                }
            }
        }
    }
public function execute($name, AnCommandContext $context)
    {
        $parts = explode('.', $name);
        $result = $context->result;

        //after an action save
        if ($parts[0] === 'after' && $parts[1] != 'cancel') {

            //skip if there are not any commitable
            if (count($this->getRepository()->getSpace()->getCommitables()) == 0) {
                return;
            }

            $result = $this->commit();

            $type = $result === false ? 'error' : 'success';
            $message = $this->_makeStatusMessage($context->action, $type);

            if ($message) {
                $this->setMessage($message, $type);
            }

            if ($result === false) {
                if ($this->isIdentifiable() && $this->getItem()) {
                    if ($this->getItem()->getErrors()->count()) {
                        throw new AnErrorException($this->getItem()->getErrors(), AnHttpResponse::BAD_REQUEST);
                        return;
                    }
                } else {
                    $errors = AnHelperArray::getValues($this->getCommitErrors());
                    throw new AnErrorException($errors, AnHttpResponse::BAD_REQUEST);
                    return;
                }
            }
        }
    }
public function execute ( $ name , AnCommandContext $ context ) { $ parts = explode ( '.' , $ name ) ; $ result = $ context -> result ; //after an action save if ( $ parts [ 0 ] === 'after' && $ parts [ 1 ] != 'cancel' ) { //skip if there are not any commitable if ( count ( $ this -> getRepository ( ) -> getSpace ( ) -> getCommitables ( ) ) == 0 ) { return ; } $ result = $ this -> commit ( ) ; $ type = $ result === false ? 'error' : 'success' ; $ message = $ this -> _makeStatusMessage ( $ context -> action , $ type ) ; if ( $ message ) { $ this -> setMessage ( $ message , $ type ) ; } if ( $ result === false ) { if ( $ this -> isIdentifiable ( ) && $ this -> getItem ( ) ) { if ( $ this -> getItem ( ) -> getErrors ( ) -> count ( ) ) { throw new AnErrorException ( $ this -> getItem ( ) -> getErrors ( ) , AnHttpResponse :: BAD_REQUEST ) ; return ; } } else { $ errors = AnHelperArray :: getValues ( $ this -> getCommitErrors ( ) ) ; throw new AnErrorException ( $ errors , AnHttpResponse :: BAD_REQUEST ) ; return ; } } } }
Executes a commit after each action. This prevents having too many
manuall commit.

@param string          $name    The command name
@param AnCommandContext $context The command context

@return bool Can return both true or false.
Executes a commit after each action . This prevents having too many manuall commit .