Example #1
0
<?php

Router::multi('/login', array('get' => 'App\\controller\\UserPublic@getLogin', 'post' => 'App\\controller\\UserPublic@postLogin'));
Router::get('/logout', function () {
    if (\App::with('User')->loggedIn()) {
        \App::with('User')->logout();
    }
    //if
    \View::redirect('/login');
});
Router::multi('/signup', array('get' => 'App\\controller\\UserPublic@getSignUp', 'post' => 'App\\controller\\UserPublic@postSignUp'));
Router::multi('/forgot-password', array('get' => 'App\\controller\\UserPublic@getForgotPassword', 'post' => 'App\\controller\\UserPublic@postForgotPassword'));
Router::get(\App\service\User::ACTIVATION_SLUG . '{token}', 'App\\controller\\UserPublic@getActivateAccount')->where('token', 'all');
Router::multi(\App\service\User::PW_RESET_SLUG . '{token}', array('get' => 'App\\controller\\UserPublic@getPasswordReset', 'post' => 'App\\controller\\UserPublic@postPasswordReset'))->where('token', 'all');
Router::auth(\App\service\User::SESSION_KEY, '/login')->filter('/user/{*}', function () {
    Router::filter('/user/{*}')->children(array('' => array('type' => 'get', 'action' => 'App\\controller\\User@getIndex'), 'edit' => array('type' => 'multi', 'action' => array('get' => 'App\\controller\\User@getEdit', 'post' => 'App\\controller\\User@postEdit'), 'children' => array('/password' => array('type' => 'post', 'action' => 'App\\controller\\User@postEditPassword')))));
});
Example #2
0
 public function testProcessRouterArray()
 {
     $_SERVER['REQUEST_URI'] = '/test/55';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $t = false;
     $routes = array('/test/{id}' => array('type' => 'get', 'action' => function () use(&$t) {
         $t = true;
         return false;
     }, 'where' => array('id' => 'integer_positive')));
     Router::filter('/test/{*}')->to($routes)->process();
     $this->assertTrue($t);
     $t = false;
     $routes = array('/test/{*}' => array('type' => 'filter', 'action' => $routes));
     Router::processRouterArray($routes);
     $this->assertTrue($t);
 }