Exemple #1
0
 public function test_auto_registration()
 {
     phpx\Macro::register('TestMacro2');
     $def = new phpx\ClassDef('MacroTestAutoRegClass');
     $def->test_macro_1('foo', 'bar');
     $def->test_macro_1('baz', 'bleem');
     $def->finalise();
     eval($def->to_php());
     $instance = new MacroTestAutoRegClass();
     assert_equal('bar', $instance->foo());
     assert_equal('bleem', $instance->baz());
 }
Exemple #2
0
            $class->inheritable_array_unshift("filters__{$chain}", $options);
        } elseif ($where == 'end') {
            $class->inheritable_array_push("filters__{$chain}", $options);
        }
    }
    public function before_filter($class, $method, $options = array())
    {
        $this->add_filter($class, 'before', 'end', $method, $options);
    }
    public function after_filter($class, $method, $options = array())
    {
        $this->add_filter($class, 'after', 'end', $method, $options);
    }
}
class RescueMacro
{
    public function rescue_from($class, $exception_class, $rescue_method)
    {
        $class->merge_inheritable_array('rescue_macro__rescues', array($exception_class => $rescue_method));
    }
}
class RecordNotFoundException extends Exception
{
}
phpx\PHPX::init();
phpx\Macro::register('\\FilterMacro');
phpx\Macro::register('\\RescueMacro');
$action = isset($_GET['action']) ? $_GET['action'] : 'index';
$params = $_GET;
$controller = new UsersController();
$controller->invoke_action($action, $params);