예제 #1
0
 /**
  * @dataProvider roleProvider
  */
 public function testRunnerWithMultiRoleInterface($roles, $resultType)
 {
     $container = new ServiceContainer();
     $generator = $container['generator'];
     $generator->registerTemplate('RecordActionTemplate', new RecordActionTemplate());
     $runner = new ActionRunner($container);
     $runner->registerAutoloader();
     $runner->registerAction('RecordActionTemplate', array('namespace' => 'OrderBundle', 'model' => 'Order', 'types' => array(['prefix' => 'Create', 'allowed_roles' => ['user', 'admin']], ['prefix' => 'Update'], ['prefix' => 'Delete'])));
     $user = new TestUser();
     $user->roles = $roles;
     $runner->setCurrentUser($user);
     $result = $runner->run('OrderBundle::Action::CreateOrder', ['qty' => '1']);
     ok($result);
     is($resultType, $result->type);
 }
예제 #2
0
 /**
  *   @expectedException  ActionKit\Exception\ActionNotFoundException
  */
 public function testRunnerWithActionNotFoundException()
 {
     $container = new ServiceContainer();
     $runner = new ActionRunner($container);
     $result = $runner->run('Product::Action::Product');
 }
예제 #3
0
    }
    public function run()
    {
        if ($this->arg('email') == '*****@*****.**' && $this->arg('password') == 'test') {
            return $this->success('登入成功');
        } else {
            if ($this->arg('email') != '*****@*****.**') {
                return $this->error('無此帳號');
            } else {
                if ($this->arg('password') != 'test') {
                    return $this->error('密碼錯誤');
                }
            }
        }
    }
}
$container = new ActionKit\ServiceContainer();
$runner = new ActionKit\ActionRunner($container);
// you can also run action directly
// $result = $runner->run('MyLoginAction',array( 'email' => '...', 'password' => '...' ));
if (isset($_POST['action'])) {
    $sig = $_POST['action'];
    unset($_POST['action']);
    $result = $runner->run($sig, $_POST);
    //var_dump($result);
    echo $result->getMessage();
} else {
    $action = new MyLoginAction();
    echo $action->asView()->render();
    // implies view class ActionKit\View\StackView
}