Ejemplo n.º 1
0
<?php

$router = new Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);
$router->notFound(array('namespace' => 'YourService\\Controllers', 'controller' => 'Index', 'action' => 'route404'));
//Add Main Controllers
$router->add('/:controller/:action/:params', array('namespace' => 'YourService\\Controllers', 'controller' => 1, 'action' => 2, 'params' => 3));
$router->add('/:controller/:action', array('namespace' => 'YourService\\Controllers', 'controller' => 1, 'action' => 2));
$router->add('/:controller', array('namespace' => 'YourService\\Controllers', 'controller' => 1));
$apiRoutes = new \Bullhorn\FastRest\Api\Services\Config\ApiRoutes('Api', 'YourService\\Controllers\\Api');
$apiRoutes->addRoutes($router);
return $router;
Ejemplo n.º 2
0
<?php

$router = new \Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);
/**
 * Frontend routes
 */
$router->add('', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'index', 'action' => 'index']);
$router->add('/', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'index', 'action' => 'index']);
$router->add('/index', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'index', 'action' => 'index']);
$router->notFound(['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'index', 'action' => 'route404']);
$router->add('/artist/{id:[0-9]+}/{name}', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'artist']);
$router->add('/album/{id:[0-9]+}/{name}', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'album']);
$router->add('/tag/{name}', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'tag']);
$router->add('/tag/{name}/{page:[0-9]+}', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'tag']);
$router->add('/search(/?)', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'search']);
$router->add('/popular', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'popular']);
$router->add('/charts', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'catalog', 'action' => 'charts']);
$router->add('/about', ['module' => 'frontend', 'namespace' => 'AlbumOrama\\Frontend\\Controllers\\', 'controller' => 'about', 'action' => 'index']);
/**
 * Backend routes
 */
return $router;
Ejemplo n.º 3
0
<?php

/*
 * Define custom routes. File gets included in the router service definition.
 */
$router = new Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);
$router->setDefaultNamespace('AllSOS\\Controllers');
// Home
$router->add('/user/signup', "User::signup");
$router->add('/user/login', "User::login");
$router->add('/user/logout', "User::logout");
$router->add('/user/logoutall', "User::logoutAll");
$router->add('/user/getinfo', "User::getInfo");
$router->add('/user/changeinfo', "User::changeInfo");
$router->add('/user/changelocation', "User::changeLocation");
$router->add('/call/make', "Call::createCall");
$router->add('/call/accept', "Call::acceptCall");
$router->add('/call/reject', "Call::rejectCall");
$router->add('/call/list', "Call::list");
$router->add('/service/list', "Service::list");
$router->add('/service/add', "Service::add");
$router->add('/user/listall', "User::listAll");
$router->notFound(array('controller' => 'ajax', 'action' => 'notFound'));
return $router;
Ejemplo n.º 4
0
<?php

/*
 * This file is part of Workflow.
 *
 * (c) sysatom <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
$router = new \Phalcon\Mvc\Router();
// home
$router->add("/", ["controller" => "index", "action" => "index"]);
// short url
$router->add("/url/{flag:[a-zA-Z]+}", ["controller" => "url", "action" => "short"]);
// 404
$router->notFound(["controller" => "error", "action" => "route404"]);
return $router;
Ejemplo n.º 5
0
<?php

$router = new \Phalcon\Mvc\Router(false);
$router->setDefaultController('index');
$router->setDefaultAction('index');
$router->setDefaultNamespace('Controllers');
$router->notFound(['controller' => 'Index', 'action' => 'error']);
$router->add('/{id:[0-9]+}', ['controller' => 'index', 'action' => 'index']);
$router->add('/', ['controller' => 'index', 'action' => 'index']);
$router->add('/login', ['controller' => 'index', 'action' => 'login']);
$router->add('/logout', ['controller' => 'index', 'action' => 'logout']);
$router->add('/(person|phone|place|user|position)', ['controller' => 1, 'action' => 'index']);
$router->add('/(person|phone|place|user|position)/([0-9]+)', ['controller' => 1, 'action' => 'index', 'params' => 2]);
$router->add('/(person|phone|place|user|position)/(add|edit|delete|index|search|copy|order)', ['controller' => 1, 'action' => 2]);
$router->add('/(person|phone|place|user|position)/(add|edit|delete|index|search|copy)/([0-9]+)', ['controller' => 1, 'action' => 2, 'params' => 3]);
return $router;
Ejemplo n.º 6
0
 define('CACHE_DATA_ADMIN', '../apps/common/caches/admin');
 define('CACHE_DATA_USERS', '../apps/common/caches/users');
 define('ADMIN_INFO', serialize(array('name' => 'Thế Phúc', 'email' => '*****@*****.**', 'mailHost' => 'smtp.gmail.com', 'mailPort' => 587, 'mailPassword' => '----')));
 /** The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework */
 $di = new \Phalcon\DI\FactoryDefault();
 /** Registering a router */
 $di['router'] = function () {
     $router = new \Phalcon\Mvc\Router();
     $router->setDefaultModule('users');
     $router->setDefaultController('index');
     $router->setDefaultAction('index');
     $adminRoutes = glob(dirname(__DIR__) . "/apps/**/routes/*.php");
     foreach ($adminRoutes as $key => $value) {
         require_once $value;
     }
     $router->notFound(array('module' => 'users', 'controller' => 'error', 'action' => 'error404'));
     $router->removeExtraSlashes(true);
     return $router;
 };
 /** The URL component is used to generate all kind of urls in the application */
 $di->set('url', function () {
     $url = new \Phalcon\Mvc\Url();
     $url->setBaseUri('/');
     return $url;
 });
 /** Start the session the first time some component request the session service */
 $di->set('session', function () {
     $session = new \Phalcon\Session\Adapter\Files();
     $session->start();
     return $session;
 });
Ejemplo n.º 7
0
 public function testNotFoundPaths()
 {
     Phalcon\Mvc\Router\Route::reset();
     $router = new Phalcon\Mvc\Router(false);
     $router->add('/static/route');
     $router->notFound(array('module' => 'module', 'namespace' => 'namespace', 'controller' => 'controller', 'action' => 'action'));
     $router->handle();
     $this->assertEquals($router->getControllerName(), 'controller');
     $this->assertEquals($router->getActionName(), 'action');
     $this->assertEquals($router->getModuleName(), 'module');
     $this->assertEquals($router->getNamespaceName(), 'namespace');
 }
Ejemplo n.º 8
0
<?php

namespace Depot;

$di = new \Phalcon\DI\FactoryDefault();
$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule('cdn');
    $router->removeExtraSlashes(true);
    $router->notFound(array('module' => 'cdn', 'controller' => 'index', 'action' => 'route404'));
    $router->add('/', array('module' => 'cdn', 'controller' => 'index', 'action' => 'index'));
    /*
     * UI
     */
    $router->add('/ui', array('module' => 'ui', 'controller' => 'index', 'action' => 'index'));
    $router->add('/ui/:controller/:action', array('module' => 'ui', 'controller' => 1, 'action' => 2));
    /*
     * Cdn
     */
    $router->add('/{uuid}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}[.]{ext:[a-z]+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}/-/{operations:.+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    $router->add('/{uuid}/-/{operations:.+}[.]{ext:[a-z]+}', array('module' => 'cdn', 'controller' => 'index', 'action' => 'deliver'));
    /*
     * Api
     */
    $router->add('/api/{version:[0-9.]+}/files', array('module' => 'api', 'controller' => 'files', 'action' => 'index'), array('GET'));
    $router->add('/api/{version:[0-9.]+}/files', array('module' => 'api', 'controller' => 'files', 'action' => 'upload'), array('POST', 'PUT'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'get'), array('GET'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'edit'), array('POST', 'PUT'));
    $router->add('/api/{version:[0-9.]+}/files/{uuid}', array('module' => 'api', 'controller' => 'files', 'action' => 'delete'), array('DELETE'));
Ejemplo n.º 9
0
Archivo: core.php Proyecto: LWFeng/xnx
// 限制主机名(Hostname Constraints)
$router->add('...', array())->setHostName('admin.company.com');
$router->add('...', array())->setHostName('([a-z+]).company.com');
Phalcon\Mvc\Router\Group::setHostName('blog.mycompany.com');
// 设置默认路径(Setting default paths)
//Setting a specific default
$router->setDefaultModule('backend');
$router->setDefaultNamespace('Backend\\Controllers');
$router->setDefaultController('index');
$router->setDefaultAction('index');
//Using an array
$router->setDefaults(array('controller' => 'index', 'action' => 'index'));
// 处理结尾额外的斜杆(Dealing with extra/trailing slashes)
$router->removeExtraSlashes(true);
// 没有找到路径(Not Found Paths)
$router->notFound(array("controller" => "index", "action" => "route404"));
$router->handle();
$di->set('router', function () {
    require __DIR__ . '/../app/config/routes.php';
    return $router;
});
// *** Url ***
$url->setBaseUri('/');
$url->setStaticBaseUri('http://static.mywebsite.com/');
$url->get("products/save");
$route->add('/blog/{$year}/{month}/{title}', array('controller' => 'posts', 'action' => 'show'))->setName('show-post');
// This produces: /blog/2012/01/some-blog-post
$url->get(array('for' => 'show-post', 'year' => 2012, 'month' => '01', 'title' => 'some-blog-post'));
// {{ url("posts/edit/1002") }}
// {{ static_url("css/style.css") }}
// *** Request ***
Ejemplo n.º 10
0
<?php

$router = new Phalcon\Mvc\Router(false);
$router->setUriSource(Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->removeExtraSlashes(true);
// index
$router->add('/', array('controller' => 'index', 'action' => 'index'));
// search
$router->add('/search', array('controller' => 'search', 'action' => 'index'));
// auth
$router->add('/login', array('controller' => 'auth', 'action' => 'login'));
$router->add('/logout', array('controller' => 'auth', 'action' => 'logout'));
$router->add('/signup', array('controller' => 'auth', 'action' => 'signup'));
// leagues
$router->add('/leagues', array('controller' => 'leagues', 'action' => 'index'));
$router->add('/leagues/{id}/:action', array('controller' => 'leagues', 'action' => '2'));
$router->add('/leagues/{id}', array('controller' => 'leagues', 'action' => 'show'));
$router->add('/leagues/new', array('controller' => 'leagues', 'action' => 'new'));
$router->add('/leagues/create', array('controller' => 'leagues', 'action' => 'create'));
// help
$router->add('/about', array('controller' => 'help', 'action' => 'about'));
// testing
$router->add('/test', array('controller' => 'index', 'action' => 'test'));
$router->add('/info', array('controller' => 'index', 'action' => 'info'));
// errors
$router->notFound(array('controller' => 'index', 'action' => 'info'));
$router->handle();
return $router;
Ejemplo n.º 11
0
<?php

$router = new Phalcon\Mvc\Router(false);
$router->notFound(array("namespace" => 'App\\Controllers', "controller" => "error", "action" => "notFound"));
$router->add('/:controller/:action/:int', array('controller' => 1, 'action' => 2, 'id' => 3))->setName('full');
$router->add('/:controller/:action', array('controller' => 1, 'action' => 2))->setName('action');
$router->add('/:controller', array('controller' => 1, 'action' => 'index'))->setName('controller');
$router->add('/{action:(login|logout)}', array('namespace' => 'App\\Controllers', 'controller' => 'index'))->setName('auth');
$router->add('/ajax/:action', array('controller' => 'ajax', 'action' => 1))->setName('ajax');
$router->add("/", array('controller' => 'index', 'action' => 'index'))->setName('main');
Ejemplo n.º 12
0
 /**
  * This methods registers the services to be used by the application
  */
 protected function _registerServices()
 {
     $di = new \Phalcon\DI\FactoryDefault();
     // Registering a Config shared-service
     $di->setShared('config', function () {
         $config['main'] = (include ROOT_DIR . "/config/main.php");
         $config['db'] = (include ROOT_DIR . "/config/db.php");
         $config['router'] = (include ROOT_DIR . "/config/router.php");
         return new \Phalcon\Config($config);
     });
     $config = $di->get('config');
     // Change FactoryDefault default Router service
     $di->getService('router')->setDefinition(function () use($config) {
         $router = new \Phalcon\Mvc\Router();
         //Setup routes from /config/router.php
         foreach ($config->router->toArray() as $key => $value) {
             $router->add($key, $value);
         }
         // Mount each module routers
         $router->mount(new \App\Frontend\Router());
         $router->mount(new \App\Backend\Router());
         // URI_SOURCE_SERVER_REQUEST_URI
         $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
         // Remove trailing slashes automatically
         $router->removeExtraSlashes(true);
         // Setting a specific default using an array
         // DefaultModule
         // DefaultNamespace
         // DefaultController
         // DefaultAction
         $router->setDefaults(array('modul' => 'frontend', 'namespace' => 'App\\Frontend\\Controllers\\', 'controller' => 'index', 'action' => 'index'));
         // Set 404 paths
         $router->notFound(["controller" => "error", "action" => "error404"]);
         return $router;
     });
     // Registering a View shared-service
     $di->setShared('view', function () {
         return new \Phalcon\Mvc\View();
     });
     // Registering a Mysql shared-service
     $di->setShared('mysql', function () use($config) {
         return new \Phalcon\Db\Adapter\Pdo\Mysql($config->db->mysql->toArray());
     });
     // Registering a Db shared-service
     $di->setShared('db', function () use($di) {
         return $di->get('mysql');
     });
     // Registering a Url shared-service
     $di->setShared('url', function () {
         $url = new \Phalcon\Mvc\Url();
         $url->setBaseUri('/');
         return $url;
     });
     // Start the Session service
     $di->get('session')->start();
     // Setup the Crypt service
     $di->get('crypt')->setMode(MCRYPT_MODE_CFB)->setKey($config->main->crypt_key);
     // Setup the Security service
     $di->get('security')->setWorkFactor(12);
     // Registering a custom authentication shared-service
     $di->setShared('auth', function () {
         return new \App\Common\Libs\Auth();
     });
     $this->setDI($di);
 }
Ejemplo n.º 13
0
$router->add("/{city}/location/location", array('controller' => 'location', 'action' => 'forwardlocation'));
$router->add("/tag/forwardtag", array('controller' => 'tag', 'action' => 'forwardtag'));
$router->add("/tag/apptesting", array('controller' => 'tag', 'action' => 'apptesting'));
$router->add("/search/index", array('controller' => 'search', 'action' => 'index'));
$router->add("/search/searchlist", array('controller' => 'search', 'action' => 'searchlist'));
$router->add("/{city}/search", array('controller' => 'search', 'action' => 'search'));
$router->add("/{city}/location", array('controller' => 'location', 'action' => 'location'));
$router->add("/{city}/events", array('controller' => 'event', 'action' => 'eventlist'));
$router->add("/search/autosuggestion", array('controller' => 'search', 'action' => 'autosuggestion'));
if (preg_match('/\\be-[0-9\\- ]+/i', $urlparams, $match)) {
    $router->add("/{city}/{eventtitle}", array('controller' => 'event', 'action' => 'index'));
}
if (preg_match('/\\bc-[0-9\\- ]+/i', $urlparams, $match)) {
    $router->add("/{city}/{contenttitle}", array('controller' => 'content', 'action' => 'index'));
}
if (preg_match('/\\bs-[0-9\\- ]+/i', $urlparams, $match)) {
    $router->add("/{city}/{specialpagetitle}", array('controller' => 'specialpage', 'action' => 'index'));
}
if (preg_match('/\\bv-[0-9\\- ]+/i', $urlparams, $match)) {
    $router->add("/{city}/{venue}", array('controller' => 'venue', 'action' => 'index'));
}
$router->add("/{city}", array('controller' => 'index', 'action' => 'homepage'));
$router->add("/policy", array('controller' => 'index', 'action' => 'policy'));
$router->add("/terms", array('controller' => 'index', 'action' => 'terms'));
$router->add("/about-us", array('controller' => 'index', 'action' => 'aboutus'));
$router->add("/search", array('controller' => 'search', 'action' => 'search'));
$router->add("/homepage", array('controller' => 'index', 'action' => 'homepage'));
$router->add("/", array('controller' => 'index', 'action' => 'index'));
$router->add("/unsubscribe/{email}", array('controller' => 'index', 'action' => 'unsubscribe'));
$router->notFound(array("controller" => "error", "action" => "route404"));
$router->handle();
Ejemplo n.º 14
0
<?php

$router = new \Phalcon\Mvc\Router(false);
$router->add("/:controller/:action", array('controller' => 1, 'action' => 2));
$router->add("/", array('controller' => 'index', 'action' => 'index'));
//Set 404 paths
$router->notFound(array("controller" => "notfound", "action" => "index"));
return $router;
Ejemplo n.º 15
0
////////////////////////////
//  VIEW SETUP
$viewDirArray = array();
////////////////////////////
//  ROOT
$di->set('url', function () {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri('/');
    return $url;
});
////////////////////////////
//  ROUTER
$router->setDefaults(array('controller' => 'index', 'action' => 'index', 'namespace' => 'Host\\Controller'));
$router->add("/extender", array('controller' => 'extender', 'action' => 'index', 'path' => $_GET['path'], 'namespace' => 'Host\\Controller'));
$router->add("/extender/extend", array('controller' => 'extender', 'action' => 'index', 'path' => $_GET['path'], 'namespace' => 'Host\\Controller'));
$router->notFound(array('controller' => 'index', 'action' => 'notFound', 'namespace' => 'Host\\Controller'));
////////////////////////////
//  BIND VIEW
Twig_Autoloader::register();
$di['twigService'] = function ($view, $di) {
    Phalcon\Mvc\View\Engine\Twig::setOptions(array('debug' => true, 'charset' => 'UTF-8', 'base_template_class' => 'Twig_Template', 'strict_variables' => false, 'autoescape' => false, 'cache' => __DIR__ . '/../../cache/twig/', 'auto_reload' => null, 'optimizations' => -1));
    $twig = new View($view, $di);
    return $twig;
};
$di->set('twigService', function ($view, $di) use($config) {
    //  create twig object
    $option = array('cache' => '../cache/');
    $arrFolder = array('../views/');
    $twig = new \Phalcon\Mvc\View\Engine\Twig($view, $di, $options, $arrFolder);
    return $twig;
}, true);
Ejemplo n.º 16
0
/* Settings Menu */
$router->add('/view/settings-menu-popover', array('namespace' => 'app\\controllers', 'controller' => 'settings', 'action' => 'menu'));
/* Photo */
$router->add('/view/profile/{uid}/photos', array('namespace' => 'app\\controllers', 'controller' => 'photo', 'action' => 'fire', 'uid' => 2));
$router->add('/view/profile/{uid}/photos/albums', array('namespace' => 'app\\controllers', 'controller' => 'photo', 'action' => 'albums'));
$router->add('/view/profile/{uid}/photos/albums/:id', array('namespace' => 'app\\controllers', 'controller' => 'photo', 'action' => 'fire'));
$router->add('/view/profile/{uid}/photos/all', array('namespace' => 'app\\controllers', 'controller' => 'photo', 'action' => 'allPhotos', 'uid' => 2));
$router->add('/view/profile/{uid}/about', array('namespace' => 'app\\controllers', 'controller' => 'profile', 'action' => 'about', 'uid' => 2));
$router->add('/view/profile/{uid}/friends', array('namespace' => 'app\\controllers', 'controller' => 'friend', 'action' => 'fire', 'uid' => 2));
$router->add('/view/profile/{uid}/timeline', array('namespace' => 'app\\controllers', 'controller' => 'feed', 'action' => 'timeline', 'params' => 2));
$router->add('/view/feeds/item/{id}', array('namespace' => 'app\\controllers', 'controller' => 'feed', 'action' => 'feedItemModal'));
/* END OF NESTED VIEWS */
/* Photo */
$router->add('/photos/:params', array('namespace' => 'app\\controllers', 'controller' => 'photo', 'action' => 'fire', 'params' => 1));
/* Profile */
$router->add('/profile/{uid}/:params', array('namespace' => 'app\\controllers', 'controller' => 'profile', 'action' => 'fire', 'params' => 2));
/* Message */
$router->add('/messages', array('namespace' => 'app\\controllers', 'controller' => 'message', 'action' => 'fire'));
$router->add('/messages/{uid}', array('namespace' => 'app\\controllers', 'controller' => 'message', 'action' => 'fire'));
/* Feed Comments */
$router->add('/feeds/item/{id}', array('namespace' => 'app\\controllers', 'controller' => 'feed', 'action' => 'feedItem'));
/* Journal (Bonus) */
$router->add('/journals', array('namespace' => 'app\\controllers', 'controller' => 'journal', 'action' => 'fire'));
/* Settings */
$router->add('/settings', array('namespace' => 'app\\controllers', 'controller' => 'settings', 'action' => 'fire'));
/* Photo Upload */
$router->add('/upload/image/:params', array('namespace' => 'app\\controllers', 'controller' => 'upload', 'action' => 'image', 'params' => 1));
/* Admin */
$router->add('/cp/:params', array('namespace' => 'app\\controllers', 'controller' => 'cp', 'action' => 'fire', 'params' => 1));
$router->notFound(array('namespace' => 'app\\controllers', 'controller' => 'socialSample', 'action' => 'notFound'));
return $router;
Ejemplo n.º 17
0
date_default_timezone_set('America/Mexico_City');
ini_set('display_errors', true);
error_reporting(E_ALL);
$di = new \Phalcon\DI\FactoryDefault();
$di->set('url', function () {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri("http://" . $_SERVER["SERVER_NAME"] . "/");
    return $url;
});
$di->set('router', function () {
    $router = new \Phalcon\Mvc\Router();
    $router->setDefaultModule("frontend");
    $router->add("/", array('module' => 'frontend', 'controller' => 'index', 'action' => 'index'));
    $router->add("/contactanos", array('module' => 'frontend', 'controller' => 'index', 'action' => 'contactanos'));
    $router->add("/token", array('module' => 'frontend', 'controller' => 'index', 'action' => 'token'));
    $router->notFound(array('module' => 'frontend', 'controller' => 'index', 'action' => 'show404'));
    /* Dashboard */
    $router->add("/dashboard", array('module' => 'dashboard', 'controller' => 'index', 'action' => 'index'));
    $router->add("/login", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'index'));
    $router->add("/logout", array('module' => 'dashboard', 'controller' => 'login', 'action' => 'logout'));
    $router->add('/dashboard/([a-zA-Z\\-]+)/([a-zA-Z\\-]+)', array('module' => 'dashboard', 'controller' => 1, 'action' => 2))->setName("controllers")->convert('action', function ($action) {
        return \Phalcon\Text::lower(\Phalcon\Text::camelize($action));
    });
    $router->removeExtraSlashes(true);
    return $router;
});
/**
 * Start the session the first time some component request the session service
 */
$di->set('dispatcher', function () use($di) {
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
Ejemplo n.º 18
0
$router->add('/tag/:params', ['controller' => 'entry', 'action' => 'tagArticle', 'tag' => 1]);
$router->add('/category/:params', ['controller' => 'entry', 'action' => 'categoryArticle', 'category' => 1]);
/**
 *  /entry/all
 */
$router->add('/entry/all', ['controller' => 'entry', 'action' => 'all']);
/**
 *  /entry/add
 */
$router->addPost('/entry/add', ['controller' => 'entry', 'action' => 'add']);
/**
 *  /entry/update/:int
 */
$router->addPost('/entry/update/:int', ['controller' => 'entry', 'action' => 'update', 'id' => 1]);
/**
 *  /entry/delete/:int
 */
$router->addPost('/entry/delete/:int', ['controller' => 'entry', 'action' => 'delete', 'id' => 1]);
/**
 *  /comment/:int
 */
$router->add('/comment/list', ['controller' => 'comment', 'action' => 'list']);
/**
 *  /comment/:int
 */
$router->addPost('/comment/:int', ['controller' => 'comment', 'action' => 'set', 'id' => 1]);
$router->notFound(array('controller' => 'status', 'action' => 'code404'));
/**
 *  末尾のスラッシュを取り除く
 */
$router->removeExtraSlashes(true);
Ejemplo n.º 19
0
<?php

// 如果不使用默认的路由规则,请传入参数false
// 此时必需完全匹配路由表,否则调用默认的index/index
$router = new Phalcon\Mvc\Router();
// 如果URL以/结尾,删除这个/
$router->removeExtraSlashes(false);
$router->add('/', ['controller' => 'home', 'action' => 'index']);
// Not Found Paths
$router->notFound(['controller' => 'index', 'action' => 'show404']);
return $router;
Ejemplo n.º 20
0
 /**
  * Set the static router service
  *
  * @package     las
  * @version     1.0
  *
  * @return void
  */
 protected function router()
 {
     $this->_di->set('router', function () {
         $router = new \Phalcon\Mvc\Router(false);
         $router->setDefaults(array('module' => 'frontend', 'controller' => 'index', 'action' => 'index'));
         /*
          * All defined routes are traversed in reverse order until Phalcon\Mvc\Router
          * finds the one that matches the given URI and processes it, while ignoring the rest.
          */
         $frontend = new \Phalcon\Mvc\Router\Group(array('module' => 'frontend'));
         $frontend->add('/:controller/:action/:params', array('controller' => 1, 'action' => 2, 'params' => 3));
         $frontend->add('/:controller/:int', array('controller' => 1, 'id' => 2));
         $frontend->add('/:controller[/]?', array('controller' => 1));
         $frontend->add('/{action:(buy|contact)}[/]?', array('controller' => 'static', 'action' => 'action'));
         $frontend->add('/');
         // Mount a group of routes for frontend
         $router->mount($frontend);
         /**
          * Define routes for each module
          */
         foreach (array('admin', 'doc') as $module) {
             $group = new \Phalcon\Mvc\Router\Group(array('module' => $module));
             $group->setPrefix('/' . $module);
             $group->add('/:controller/:action/:params', array('controller' => 1, 'action' => 2, 'params' => 3));
             $group->add('/:controller/:int', array('controller' => 1, 'id' => 2));
             $group->add('/:controller[/]?', array('controller' => 1));
             $group->add('[/]?', array());
             // Mount a group of routes for some module
             $router->mount($group);
         }
         $router->notFound(array('controller' => 'index', 'action' => 'notFound'));
         return $router;
     });
 }
Ejemplo n.º 21
0
<?php

$router = new Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);
$router->setDefaults(array('controller' => 'apireference', 'action' => 'index'));
$router->add('/error/404', array('controller' => 'error', 'action' => '_404'))->setName('404');
$router->notFound($router->getRouteByName('404')->getPaths());
// this only need to get URL to class reference by route name
$router->add('/{language:[A-Za-z]{2,2}}/{version:((\\d+\\.\\d+\\.\\d+)|latest)}/{class:(?i)phalcon(/[\\w/]+)?}', array('controller' => 'apireference', 'action' => 'showClass'))->setName('showClass');
// this only need to get URL by route name
$router->add('/{language:[A-Za-z]{2,2}}/{version:((\\d+\\.\\d+\\.\\d+)|latest)}/{type:(classes|namespaces|interfaces|changelog)}', array('controller' => 'apireference', 'action' => 'index'))->setName('showSummary');
$router->add('/?([A-Za-z]{2,2})?(/((\\d+\\.\\d+\\.\\d+)|latest))?(/(classes|namespaces|interfaces|changelog))?', array('controller' => 'apireference', 'action' => 'index', 'language' => 1, 'version' => 3, 'summary' => 6))->convert('language', function ($param) {
    return $param === 1 || !$param ? null : strtolower($param);
})->convert('version', function ($param) {
    return $param === 3 || !$param ? null : $param;
})->convert('summary', function ($param) {
    return $param === 6 || !$param ? 'classes' : $param;
});
$router->add('(/([A-Za-z]{2,2}))?(/((\\d+\\.\\d+\\.\\d+)|latest))?/((?i)phalcon(/[\\w/]+)?)', array('controller' => 'apireference', 'action' => 'showClass', 'language' => 2, 'version' => 4, 'class' => 6))->convert('language', function ($param) {
    return $param === 2 || !$param ? null : strtolower($param);
})->convert('version', function ($param) {
    return $param === 4 || !$param ? null : $param;
})->convert('class', function ($param) {
    return $param === 6 || !$param ? null : str_replace('/', '\\', strtolower($param));
});
return $router;
Ejemplo n.º 22
0
 protected function router()
 {
     //Setting up the static router
     $this->_di->set('router', function () {
         $router = new \Phalcon\Mvc\Router(FALSE);
         $router->setDefaults(array('module' => 'home', 'controller' => 'Index', 'action' => 'index'));
         //前台
         $router->add('/', array('module' => 'home', 'controller' => 'Index', 'action' => 'index'));
         $router->add('/:controller[/]?', array('module' => 'home', 'controller' => 1, 'action' => 'index'));
         $router->add('/:controller/:action/:params', array('module' => 'home', 'controller' => 1, 'action' => 2, 'params' => 3));
         $router->add('/:int[/]?', array('module' => 'home', 'controller' => 'index', 'action' => 'index', 'node' => 1));
         $router->add('/:int/:controller[/]?', array('module' => 'home', 'controller' => 2, 'action' => 'index', 'node' => 1));
         $router->add('/:int/:controller/:action/:params', array('module' => 'home', 'controller' => 2, 'action' => 3, 'node' => 1, 'params' => 4));
         //后台
         $router->add('/admin[/]?', array('module' => 'admin', 'controller' => 'Index', 'action' => 'index'));
         $router->add('/admin/:controller[/]?', array('module' => 'admin', 'controller' => 1, 'action' => 'index'));
         $router->add('/admin/:controller/:action/:params', array('module' => 'admin', 'controller' => 1, 'action' => 2, 'params' => 3));
         $router->add('/:int/admin[/]?', array('module' => 'admin', 'controller' => 'Index', 'action' => 'index', 'node' => 1));
         $router->add('/:int/admin/:controller[/]?', array('module' => 'admin', 'controller' => 2, 'action' => 'index', 'node' => 1));
         $router->add('/:int/admin/:controller/:action/:params', array('module' => 'admin', 'controller' => 2, 'action' => 3, 'params' => 4, 'node' => 1));
         //任务
         $router->add('/backend[/]?', array('module' => 'backend', 'controller' => 'Index', 'action' => 'index'));
         $router->add('/backend/:controller[/]?', array('module' => 'backend', 'controller' => 1, 'action' => 'index'));
         $router->add('/backend/:controller/:action/:params', array('module' => 'backend', 'controller' => 1, 'action' => 2, 'params' => 3));
         $router->add('/:int/backend[/]?', array('module' => 'backend', 'controller' => 'Index', 'action' => 'index', 'node' => 1));
         $router->add('/:int/backend/:controller[/]?', array('module' => 'backend', 'controller' => 2, 'action' => 'index', 'node' => 1));
         $router->add('/:int/backend/:controller/:action/:params', array('module' => 'backend', 'controller' => 2, 'action' => 3, 'params' => 4, 'node' => 1));
         //404
         $router->notFound(array('controller' => 'index', 'action' => 'notFound'));
         return $router;
     });
 }