private function sendToStatusInternal($status, $delayed)
	{
		$this->_pendingEvents = [];

		list($newStatus, , $events) = $this->createTransitionItems($status, false, true);
		
		$delayedStop = false;
		if ( ! empty($events['before']) ) {
			foreach ($events['before'] as $eventBefore) {
				$this->owner->trigger($eventBefore->name, $eventBefore);
				if ( $eventBefore->isValid === false) {
					if ( $this->propagateErrorsToModel === true && count($eventBefore->getErrors()) != 0 ) {
						$this->owner->addErrors([ $this->statusAttribute => $eventBefore->getErrors() ]);
					}
					if($this->stopOnFirstInvalidEvent === true) {
						return false;
					} else {
						$delayedStop = true;
					}
				}
			}
		}
		if( $delayedStop ) {
			return false;
		}

		$this->setStatusInternal($newStatus);

		if ( ! empty($events['after']) ) {
			if ( $delayed ) {
				$this->_pendingEvents = $events['after'];
			} else {
				foreach ($events['after'] as $eventAfter) {
					$this->owner->trigger($eventAfter->name, $eventAfter);
				}
			}
		}

		if ($this->getStatusAccessor() != null) {
			$this->_statusAccessor->updateStatus($this->owner, $newStatus);
		}
		return true;
	}
private function sendToStatusInternal($status, $delayed)
	{
		$this->_pendingEvents = [];

		list($newStatus, , $events) = $this->createTransitionItems($status, false, true);
		
		$delayedStop = false;
		if ( ! empty($events['before']) ) {
			foreach ($events['before'] as $eventBefore) {
				$this->owner->trigger($eventBefore->name, $eventBefore);
				if ( $eventBefore->isValid === false) {
					if ( $this->propagateErrorsToModel === true && count($eventBefore->getErrors()) != 0 ) {
						$this->owner->addErrors([ $this->statusAttribute => $eventBefore->getErrors() ]);
					}
					if($this->stopOnFirstInvalidEvent === true) {
						return false;
					} else {
						$delayedStop = true;
					}
				}
			}
		}
		if( $delayedStop ) {
			return false;
		}

		$this->setStatusInternal($newStatus);

		if ( ! empty($events['after']) ) {
			if ( $delayed ) {
				$this->_pendingEvents = $events['after'];
			} else {
				foreach ($events['after'] as $eventAfter) {
					$this->owner->trigger($eventAfter->name, $eventAfter);
				}
			}
		}

		if ($this->getStatusAccessor() != null) {
			$this->_statusAccessor->updateStatus($this->owner, $newStatus);
		}
		return true;
	}
private function sendToStatusInternal ( $ status , $ delayed ) { $ this -> _pendingEvents = [ ] ; list ( $ newStatus , , $ events ) = $ this -> createTransitionItems ( $ status , false , true ) ; $ delayedStop = false ; if ( ! empty ( $ events [ 'before' ] ) ) { foreach ( $ events [ 'before' ] as $ eventBefore ) { $ this -> owner -> trigger ( $ eventBefore -> name , $ eventBefore ) ; if ( $ eventBefore -> isValid === false ) { if ( $ this -> propagateErrorsToModel === true && count ( $ eventBefore -> getErrors ( ) ) != 0 ) { $ this -> owner -> addErrors ( [ $ this -> statusAttribute => $ eventBefore -> getErrors ( ) ] ) ; } if ( $ this -> stopOnFirstInvalidEvent === true ) { return false ; } else { $ delayedStop = true ; } } } } if ( $ delayedStop ) { return false ; } $ this -> setStatusInternal ( $ newStatus ) ; if ( ! empty ( $ events [ 'after' ] ) ) { if ( $ delayed ) { $ this -> _pendingEvents = $ events [ 'after' ] ; } else { foreach ( $ events [ 'after' ] as $ eventAfter ) { $ this -> owner -> trigger ( $ eventAfter -> name , $ eventAfter ) ; } } } if ( $ this -> getStatusAccessor ( ) != null ) { $ this -> _statusAccessor -> updateStatus ( $ this -> owner , $ newStatus ) ; } return true ; }
Performs status change and event fire.

This method is called when the owner model is about to change status. This occurs when it is saved, deleted, or when
a call is done to `sendToStatus()`

Based on the current value of the owner model status attribute and the internal behavior status, it checks if a transition
is about to occur. If that's the case, this method fires all "before" events provided by the event sequence component
and then updates status attributes values (both internal and at the owner model level).
Finallly it fires the "after" events, or if we are in a save or delete operation, store them as pending events that are fired
on the *afterSave" or afterDelete event.
Note that if an event handler attached to a "before" event sets the event instance as invalid, all remaining handlers
are ingored and the method returns immediately.

@param mixed $status the target status or NULL when leaving the workflow
@param boolean $delayed if TRUE, all 'after' events are not fire but stored for being fired in AfterSave or afterDelete. This occurs
when the transition is performed on a save or delete action.
@return boolean
Performs status change and event fire .