当前位置: 首页>>代码示例>>PHP>>正文


PHP Router::setUriSource方法代码示例

本文整理汇总了PHP中Phalcon\Mvc\Router::setUriSource方法的典型用法代码示例。如果您正苦于以下问题:PHP Router::setUriSource方法的具体用法?PHP Router::setUriSource怎么用?PHP Router::setUriSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Mvc\Router的用法示例。


在下文中一共展示了Router::setUriSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createFrom

 /**
  * @param array $routes
  * @return MvcRouter
  */
 public static function createFrom(array $routes) : MvcRouter
 {
     $router = new MvcRouter(false);
     $router->setUriSource(MvcRouter::URI_SOURCE_SERVER_REQUEST_URI);
     $router->removeExtraSlashes(true);
     foreach ($routes as $route) {
         $router->add($route['pattern'], $route['paths'] ?? null, $route['httpMethods'] ?? null, $route['position'] ?? MvcRouter::POSITION_LAST);
     }
     return $router;
 }
开发者ID:mamuz,项目名称:phalcon-application,代码行数:14,代码来源:Router.php

示例2: Router

<?php

use Phalcon\Mvc\Router, Phalcon\Mvc\Router\Group as RouterGroup;
$router = new Router(false);
$router->setDefaultModule(SITENAME);
$router->removeExtraSlashes(true);
$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->add('/', array('controller' => 'Index', 'action' => 'index'))->setName('homepage');
$router->add('/testMenu/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Index', 'action' => 'testMenu'))->setName('homepage-test');
$router->add('/menu/ajax/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Index', 'action' => 'menuAjax'))->setName('homepage-ajax');
/*
  Orders
*/
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'index'))->setName('order');
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}/{drink_id:[a-z0-9\\-_A-Z]+}/{coldheat_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'orderDrink'))->setName('order-drink');
$router->add('/order/{order_id:[a-z0-9\\-_A-Z]+}/overview', array('controller' => 'Order', 'action' => 'orderOverview'))->setName('order');
$router->add('/order/add-drink', array('controller' => 'Order', 'action' => 'addDrink'))->setName('order-add-drink');
/*
  resouces
*/
$router->add('/resource/stores', array('controller' => 'Resource', 'action' => 'stores'))->setName('resouce-stores');
$router->add('/resource/oStore/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderStore'))->setName('resouce-order-store');
$router->add('/resource/oDrink/{drink_id:[a-z0-9\\-_A-Z]+}/{coldheat_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderDrink'))->setName('resouce-drink-detail');
$router->add('/resource/oDrinkList/{order_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Resource', 'action' => 'orderDrinkList'))->setName('resouce-drink-detail');
$router->add('/order/hook/{store_id:[a-z0-9\\-_A-Z]+}', array('controller' => 'Order', 'action' => 'hookOrder'))->setName('order-hook');
$router->notFound(array('controller' => 'Index', 'action' => 'notFound'));
开发者ID:inno-v,项目名称:LinInLiao,代码行数:26,代码来源:Frontend.php

示例3: FactoryDefault

use Phalcon\Mvc\Router;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\DI\FactoryDefault;
use Phalcon\Session\Adapter\Files as SessionAdapter;
/**
 * The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
 */
$di = new FactoryDefault();
/**
 * Registering a router
 */
$di['router'] = function () {
    $router = new Router();
    $router->setDefaultModule("frontend");
    $router->setDefaultNamespace("Modules\\Modules\\Frontend\\Controllers");
    $router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
    $router->removeExtraSlashes(TRUE);
    return $router;
};
/**
 * The URL component is used to generate all kind of urls in the application
 */
$di['url'] = function () {
    $url = new UrlResolver();
    $url->setBaseUri('/');
    return $url;
};
/**
 * Start the session the first time some component request the session service
 */
$di['session'] = function () {
开发者ID:boiler256,项目名称:mvc,代码行数:31,代码来源:services.php

示例4: _registerServices

 /**
  * This methods registers the services to be used by the application
  */
 protected function _registerServices()
 {
     $di = new DI();
     //Registering a router
     $di->set('router', function () {
         $router = new MvcRouter();
         $router->setUriSource(MvcRouter::URI_SOURCE_SERVER_REQUEST_URI);
         foreach (include ROOT_DIR . "/config/router.php" as $key => $value) {
             $router->add($key, $value);
         }
         return $router;
     });
     //Registering a dispatcher
     $di->set('dispatcher', function () {
         //Create an EventsManager
         $eventsManager = new EventsManager();
         //Attach a listener
         $eventsManager->attach("dispatch", function ($event, $dispatcher, $exception) {
             //Handle controller or action doesn't exist
             if ($event->getType() == 'beforeException') {
                 switch ($exception->getCode()) {
                     case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
                     case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                         $dispatcher->forward(['controller' => 'error', 'action' => 'index', 'params' => ['message' => $exception->getMessage()]]);
                         return false;
                 }
             }
         });
         $dispatcher = new MvcDispatcher();
         $dispatcher->setDefaultNamespace('App\\Controllers\\');
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
     //Registering a Http\Response
     $di->set('response', function () {
         return new Response();
     });
     //Registering a Http\Request
     $di->set('request', function () {
         return new Request();
     });
     //Registering the view component
     $di->set('view', function () {
         $view = new MvcView();
         $view->setViewsDir(ROOT_DIR . '/app/Views/');
         return $view;
     });
     /*$di->set('view', function(){
           $view = new MvcView();
           $view->setViewsDir(ROOT_DIR . '/app/Views/');
           $view->registerEngines([
               '.html' => function($view, $di) {
                   $smarty = new \Phalbee\Base\View\Engine\Smarty($view, $di);
                   $smarty->setOptions([
                       'left_delimiter' => '<{',
                       'right_delimiter' => '}>',
                       'template_dir'      => ROOT_DIR . '/app/Views',
                       'compile_dir'       => ROOT_DIR . '/runtime/Smarty/compile',
                       'cache_dir'         => ROOT_DIR . '/runtime/Smarty/cache',
                       'error_reporting'   => error_reporting() ^ E_NOTICE,
                       'escape_html'       => true,
                       'force_compile'     => false,
                       'compile_check'     => true,
                       'caching'           => false,
                       'debugging'         => true,
                   ]);
                   return $smarty;
               },
           ]);
           return $view;
       });*/
     $di->set('smarty', function () {
         $smarty = new \Smarty();
         $options = ['left_delimiter' => '<{', 'right_delimiter' => '}>', 'template_dir' => ROOT_DIR . '/app/Views', 'compile_dir' => ROOT_DIR . '/runtime/Smarty/compile', 'cache_dir' => ROOT_DIR . '/runtime/Smarty/cache', 'error_reporting' => error_reporting() ^ E_NOTICE, 'escape_html' => true, 'force_compile' => false, 'compile_check' => true, 'caching' => false, 'debugging' => true];
         foreach ($options as $k => $v) {
             $smarty->{$k} = $v;
         }
         return $smarty;
     });
     $di->set('db', function () {
         $db = (include ROOT_DIR . "/config/db.php");
         return new Database($db);
     });
     //Registering the Models-Metadata
     $di->set('modelsMetadata', function () {
         return new MvcModelMetadataMemory();
     });
     //Registering the Models Manager
     $di->set('modelsManager', function () {
         return new MvcModelsManager();
     });
     $this->setDI($di);
 }
开发者ID:fenghuilee,项目名称:phalbee,代码行数:96,代码来源:app.php

示例5: setUriSource

 public function setUriSource($uriSource)
 {
     return parent::setUriSource($uriSource);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Router.php


注:本文中的Phalcon\Mvc\Router::setUriSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。