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


PHP Router::setDI方法代码示例

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


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

示例1: __construct

 /**
  * @param Router|null $router
  * @param Url|null $url
  */
 public function __construct(Router $router = null, Url $url = null)
 {
     $di = new DI();
     $di->setShared('request', new PhalconRequest());
     if ($router instanceof PhalconRouterInterface) {
         $this->router = $router;
     } elseif ($router === null) {
         $this->router = new Router();
         $this->router->clear();
     } else {
         throw new Exception\RuntimeException('Router has to be an instance of RouterInterface');
     }
     $this->router->setDI($di);
     $di->setShared('router', $this->router);
     if ($url instanceof UrlInterface) {
         $this->url = $url;
     } elseif ($url === null) {
         $this->url = new Url();
         $this->url->setBaseUri('/');
     } else {
         throw new Exception\RuntimeException('Url has to be an instance of UrlInterface');
     }
     $this->url->setDI($di);
 }
开发者ID:theDisco,项目名称:phalcon-expressive,代码行数:28,代码来源:PhalconRouter.php

示例2: testAnnotations

 public function testAnnotations()
 {
     $di = new Di();
     $di['request'] = new \Phalcon\Http\Request();
     $router = new Router(false);
     $router->setDI($di);
     $loader = new ArrayRouteLoader($router);
     $loader->load(include __DIR__ . '/Fixtures/routes.php');
     $router->handle();
     $this->assertCount(3, $router->getRoutes());
     $routes = [['uri' => '/test4', 'method' => 'GET', 'controller' => 'test4', 'action' => 'test4'], ['uri' => '/test4', 'method' => 'POST', 'controller' => 'test4', 'action' => 'test4'], ['uri' => '/test5', 'method' => 'POST', 'controller' => 'test5', 'action' => 'test5'], ['uri' => '/test6', 'method' => 'GET', 'controller' => 'test6', 'action' => 'test6']];
     foreach ($routes as $route) {
         $_SERVER['REQUEST_METHOD'] = $route['method'];
         $router->handle($route['uri']);
         $this->assertEquals($router->getControllerName(), $route['controller']);
         $this->assertEquals($router->getActionName(), $route['action']);
         $this->assertEquals($router->isExactControllerName(), true);
     }
 }
开发者ID:ant-hill,项目名称:phalcon-kernel-module,代码行数:19,代码来源:ArrayRouterTest.php

示例3: Router

<?php

/**
 * Created by PhpStorm.
 * User: rcmonitor
 * Date: 07.07.15
 * Time: 15:46
 */
use Phalcon\Di;
use Phalcon\Events\Manager;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Router;
use Phalcon\Version;
$di = new Di\FactoryDefault();
$oRouter = new Router(false);
$oRouter->setDI($di);
$oRouter->add('/:controller', array('controller' => 1, 'action' => 'index'));
$oEventManager = new Manager();
$oEventManager->attach('dispatch:beforeDispatch', function () {
    return false;
});
$oDispatcher = new Dispatcher();
$oDispatcher->setDI($di);
$oDispatcher->setEventsManager($oEventManager);
$oRouter->handle('/test');
$oDispatcher->setControllerName($oRouter->getControllerName());
$oDispatcher->setActionName($oRouter->getActionName());
$oDispatcher->dispatch();
echo $oDispatcher->getControllerClass() . PHP_EOL;
echo Version::get() . PHP_EOL;
开发者ID:rcmonitor,项目名称:abboom_phalcon_code_example,代码行数:30,代码来源:discussion.php

示例4: setDI

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


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