public function process(
        callable $callback = null,
        callable $successCallback = null,
        callable $failureCallback = null
    ) {
        if ($this->processed() === true) {
            // Do not process twice, ever.
            return null;
        }

        $email = $this->emailFactory()->create('email');

        $email->setData($this->data());

        try {
            $res = $email->send();
            if ($res === true) {
                $this->setProcessed(true);
                $this->setProcessedDate('now');
                $this->update(['processed', 'processed_date']);

                if ($successCallback !== null) {
                    $successCallback($this);
                }
            } else {
                if ($failureCallback !== null) {
                    $failureCallback($this);
                }
            }

            if ($callback !== null) {
                $callback($this);
            }

            return $res;
        } catch (Exception $e) {
            // Todo log error
            if ($failureCallback !== null) {
                $failureCallback($this);
            }

            return false;
        }
    }
public function process(
        callable $callback = null,
        callable $successCallback = null,
        callable $failureCallback = null
    ) {
        if ($this->processed() === true) {
            // Do not process twice, ever.
            return null;
        }

        $email = $this->emailFactory()->create('email');

        $email->setData($this->data());

        try {
            $res = $email->send();
            if ($res === true) {
                $this->setProcessed(true);
                $this->setProcessedDate('now');
                $this->update(['processed', 'processed_date']);

                if ($successCallback !== null) {
                    $successCallback($this);
                }
            } else {
                if ($failureCallback !== null) {
                    $failureCallback($this);
                }
            }

            if ($callback !== null) {
                $callback($this);
            }

            return $res;
        } catch (Exception $e) {
            // Todo log error
            if ($failureCallback !== null) {
                $failureCallback($this);
            }

            return false;
        }
    }
public function process ( callable $ callback = null , callable $ successCallback = null , callable $ failureCallback = null ) { if ( $ this -> processed ( ) === true ) { // Do not process twice, ever. return null ; } $ email = $ this -> emailFactory ( ) -> create ( 'email' ) ; $ email -> setData ( $ this -> data ( ) ) ; try { $ res = $ email -> send ( ) ; if ( $ res === true ) { $ this -> setProcessed ( true ) ; $ this -> setProcessedDate ( 'now' ) ; $ this -> update ( [ 'processed' , 'processed_date' ] ) ; if ( $ successCallback !== null ) { $ successCallback ( $ this ) ; } } else { if ( $ failureCallback !== null ) { $ failureCallback ( $ this ) ; } } if ( $ callback !== null ) { $ callback ( $ this ) ; } return $ res ; } catch ( Exception $ e ) { // Todo log error if ( $ failureCallback !== null ) { $ failureCallback ( $ this ) ; } return false ; } }
Process the item.

@param  callable $callback        An optional callback routine executed after the item is processed.
@param  callable $successCallback An optional callback routine executed when the item is resolved.
@param  callable $failureCallback An optional callback routine executed when the item is rejected.
@return boolean|null  Success / Failure
Process the item .