$props = $class::observers(get_class($this));
and set properties on the observer class from there. Specifically, I've run into an issue where if I use the same observer more than once on the same model, with different settings, I can't get their settings using the above method.call_user_func(array($observer, 'orm_notify'), $this, $event, $settings);
public static function orm_notify($instance, $event, $settings = array())
{
$model_class = get_class($instance);
if (method_exists(static::instance($model_class), $event))
{
static::instance($model_class, $settings)->{$event}($instance);
}
}
/**
* Create an instance of this observer
*
* @param string name of the model class
*/
public static function instance($model_class, $settings = array())
{
$observer = get_called_class();
if (empty(static::$_instances[$observer][$model_class]))
{
static::$_instances[$observer][$model_class] = new static($model_class, $settings);
}
return static::$_instances[$observer][$model_class];
}
It looks like you're new here. If you want to get involved, click one of these buttons!