lib/CallBack.php
public function invoke($model, $name, $mustExist=true)
	{

		// Check if callback exists
		if ($mustExist && !array_key_exists($name, $this->registry)) {
			throw new ActiveRecordException("No callbacks were defined for: $name on " . get_class($model));
		}

		// if it doesn't exist it might be a /(after|before)_(create|update)/ so we still need to run the Save callback
		if (!array_key_exists($name, $this->registry)) {
			$registry = array();
		} else {
			$registry = $this->registry[$name];
		}

		//@TODO: Make this work with the new names, and a preg_match...
		//
		// starts with /(after|before)_(create|update)/
		// 
		if (preg_match('/^(?<when>after|before)(?<action>Create|Update)$/', $name, $matches))
		{

			// Replace action with Save
			$temporalSave = $matches['when'] . "Save";

			if (!isset($this->registry[$temporalSave]))
				$this->registry[$temporalSave] = array();

			$registry = array_merge($this->registry[$temporalSave], $registry ? $registry : array());
		}
		

		if ($registry)
		{
			foreach ($registry as $method)
			{
				$ret = ($method instanceof Closure ? $method($model) : $model->$method());

				if (false === $ret && $first === 'before')
					return false;
			}
		}
		return true;
	}
public function invoke($model, $name, $mustExist=true)
	{

		// Check if callback exists
		if ($mustExist && !array_key_exists($name, $this->registry)) {
			throw new ActiveRecordException("No callbacks were defined for: $name on " . get_class($model));
		}

		// if it doesn't exist it might be a /(after|before)_(create|update)/ so we still need to run the Save callback
		if (!array_key_exists($name, $this->registry)) {
			$registry = array();
		} else {
			$registry = $this->registry[$name];
		}

		//@TODO: Make this work with the new names, and a preg_match...
		//
		// starts with /(after|before)_(create|update)/
		// 
		if (preg_match('/^(?<when>after|before)(?<action>Create|Update)$/', $name, $matches))
		{

			// Replace action with Save
			$temporalSave = $matches['when'] . "Save";

			if (!isset($this->registry[$temporalSave]))
				$this->registry[$temporalSave] = array();

			$registry = array_merge($this->registry[$temporalSave], $registry ? $registry : array());
		}
		

		if ($registry)
		{
			foreach ($registry as $method)
			{
				$ret = ($method instanceof Closure ? $method($model) : $model->$method());

				if (false === $ret && $first === 'before')
					return false;
			}
		}
		return true;
	}
public function invoke ( $ model , $ name , $ mustExist = true ) { // Check if callback exists if ( $ mustExist && ! array_key_exists ( $ name , $ this -> registry ) ) { throw new ActiveRecordException ( "No callbacks were defined for: $name on " . get_class ( $ model ) ) ; } // if it doesn't exist it might be a /(after|before)_(create|update)/ so we still need to run the Save callback if ( ! array_key_exists ( $ name , $ this -> registry ) ) { $ registry = array ( ) ; } else { $ registry = $ this -> registry [ $ name ] ; } //@TODO: Make this work with the new names, and a preg_match... // // starts with /(after|before)_(create|update)/ //  if ( preg_match ( '/^(?<when>after|before)(?<action>Create|Update)$/' , $ name , $ matches ) ) { // Replace action with Save $ temporalSave = $ matches [ 'when' ] . "Save" ; if ( ! isset ( $ this -> registry [ $ temporalSave ] ) ) $ this -> registry [ $ temporalSave ] = array ( ) ; $ registry = array_merge ( $ this -> registry [ $ temporalSave ] , $ registry ? $ registry : array ( ) ) ; } if ( $ registry ) { foreach ( $ registry as $ method ) { $ ret = ( $ method instanceof Closure ? $ method ( $ model ) : $ model -> $ method ( ) ) ; if ( false === $ ret && $ first === 'before' ) return false ; } } return true ; }
Invokes a callback.

@internal This is the only piece of the CallBack class that carries its own logic for the
model object. For (after|before)_(create|update) callbacks, it will merge with
a generic 'save' callback which is called first for the lease amount of precision.

@param string 	Model to invoke the callback on.
@param string  	Name of the callback to invoke
@param boolean  	Set to true to raise an exception if the callback does not exist.
@return mixed null if $name was not a valid callback type or false if a method was invoked
that was for a before_* callback and that method returned false. If this happens, execution
of any other callbacks after the offending callback will not occur.
Invokes a callback .