Example #1
0
<?php

use Mariana\Framework\Router;
# DEFAULT REQUEST - 1 ALLOWED EACH
Router::$defaultGet = '/';
Router::$defaultPost = '/';
# VALID GET REQUESTS
# Common Routes
Router::get('/', array('controller' => 'ViewsController', 'method' => 'index', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AuthMiddleware', 'checkLevel', array()), array('AccountConfigurationMiddleware', 'check_first_report_exists', array()))));
Router::get('/signin/', array('controller' => 'ViewsController', 'method' => 'signin', 'middleware' => array(array('AuthMiddleware', 'checkNotAuth', array()))));
Router::get('/signup/', array('controller' => 'ViewsController', 'method' => 'signup', 'middleware' => array(array('AuthMiddleware', 'checkNotAuth', array()))));
Router::get('/signout/', array('controller' => 'AuthController', 'method' => 'signout', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/messages/', array('controller' => 'ViewsController', 'method' => 'chat', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AccountConfigurationMiddleware', 'check_first_report_exists', array()))));
Router::get('/diary/', array('controller' => 'ViewsController', 'method' => 'diary', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/diary/{id}/', array('controller' => 'ViewsController', 'method' => 'diary', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/workout/', array('controller' => 'ViewsController', 'method' => 'workout', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/workout/{id}/', array('controller' => 'ViewsController', 'method' => 'workout', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
# User Routes
Router::get('/user/first-report/', array('controller' => 'ViewsController', 'method' => 'first_report', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AccountConfigurationMiddleware', 'check_first_report_not_exists', array()))));
Router::get('/user/report/', array('controller' => 'ViewsController', 'method' => 'report', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AccountConfigurationMiddleware', 'check_first_report_exists', array()))));
Router::get('/user/files/', array('controller' => 'ViewsController', 'method' => 'files', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/user/diet/', array('controller' => 'ViewsController', 'method' => 'diet', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
//Router::get('/user/diet/make-a-plan/',array('controller'    =>  'ViewsController', 'method'        =>  'makePlan', 'middleware'    =>  array(array('AuthMiddleware', 'checkAuth',array()))));
Router::get('/user/diet/adapt-a-recipe/', array('controller' => 'ViewsController', 'method' => 'adaptRecipe', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/user/diet/add-a-recipe/', array('controller' => 'ViewsController', 'method' => 'createRecipe', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::get('/user/diet/my-recipes/', array('controller' => 'ViewsController', 'method' => 'myRecipes', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::post('/user/diet/basic-plan/', array('controller' => 'DietController', 'method' => 'basicPlan', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()))));
Router::post('/user/diet/new/', array('controller' => 'DietController', 'method' => 'newRecipe', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AccountConfigurationMiddleware', 'check_first_report_not_exists', array()))));
Router::post('/user/diet/adapt/', array('controller' => 'DietController', 'method' => 'adaptRecipe', 'middleware' => array(array('AuthMiddleware', 'checkAuth', array()), array('AccountConfigurationMiddleware', 'check_first_report_not_exists', array()))));
//TODO: Acabar estas routes
# Forum Routes
Example #2
0
<?php

/**
 * Created by PhpStorm.
 * User: filipe_2
 * Date: 12/18/2015
 * Time: 9:41 PM
 */
use Mariana\Framework\Router;
# VALID GET REQUESTS
Router::get("/", array("controller" => "TestController", "method" => "index", 'middleware' => array(array('AuthMiddleware', 'check_if_logged_in', array('a', 'b')))));
Router::post("/login", array("controller" => "AuthController", "method" => "login"));
Router::get("/home/", array("controller" => "TestController", "method" => "index_2"));
Router::get("/home/user/", array("controller" => "TestController", "method" => "index_3"));
Router::get("/home/{userid}/", array("controller" => "TestController", "method" => "index_4"));
Router::get("/home/user/{userid}/", array("controller" => "TestController", "method" => "index_5", "middleware" => array("before" => array("method 1"), "after" => array("methods"))));
# VALID POST REQUESTS
Router::post("/", array("controller" => "TestController", "method" => "post_test"));
# DEFAULT REQUEST - 1 ALLOWED EACH
Router::$defaultGet = "/";
Router::$defaultPost = "/";