Ejemplo n.º 1
0
 public static function process()
 {
     # Get the request object
     $request = static::get();
     # Get the corresponding response from the cache
     if ($response = $request->cache->get()) {
         # Nothing to do
     } else {
         # Generate the response
         $response = Router::process($request);
         # Store the response in the cache
         $request->cache->set($response);
     }
     # Send the response
     $response->send();
 }
Ejemplo n.º 2
0
<?php

$loader = (require __DIR__ . '/vendor/autoload.php');
$loader->add('Custom\\', __DIR__);
use Sedra\App;
use Sedra\Locale;
use Sedra\Router;
use Sedra\Request;
use Sedra\Response;
# Enable custom locales
Locale::enable(array('fr_BE', 'en_US'));
# Setup the router
Router::setup(array('rewrite' => true));
# Configure & register the Sedra CMS and core controllers
App::register(new Sedra\Controller\i18n());
App::register(new Sedra\Controller\Admin());
App::register(new Sedra\Controller\Sedra(array('site_name' => 'My amazing website')));
# Add custom controllers
App::register(new Sedra\Controller\Blog());
App::register(new Custom\Controller\MyPhotoGallery());
# Process the request
App::process();
Ejemplo n.º 3
0
 function __construct($options)
 {
     parent::__construct($options);
     Router::option('default_route') or Router::setup(array('default_route' => 'SedraIndex'));
 }
Ejemplo n.º 4
0
namespace Sedra;

use Sedra\App;
use Sedra\Controller;
use Sedra\Locale;
use Sedra\Request;
use Sedra\Request\HTTP as HTTPRequest;
use Sedra\Response;
use Sedra\Response\HTTP\Error as HTTPErrorResponse;
use Sedra\Router\Route;
use Sedra\Router\Exception as RouterException;
use Sedra\Router\RouteProvider;
use Sedra\Router\Exception\NoSuchRoute as NoSuchRouteException;
use Sedra\Router\Exception\RouteNotFound as RouteNotFoundException;
Router::setup(array('script_file' => basename($_SERVER["SCRIPT_NAME"]), 'script_folder' => rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/'));
/**
 *
 **/
class Router
{
    protected static $options = array('rewrite' => false);
    public static function setup(array $options = array())
    {
        static::$options = $options + static::$options;
    }
    public static function option($name, $default = null)
    {
        return array_key_exists($name, static::$options) ? static::$options[$name] : $default;
    }
    public static function get_route($route_name)