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


PHP Router::connect方法代码示例

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


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

示例1: tearDown

 public function tearDown()
 {
     Router::reset();
     foreach ($this->_routes as $route) {
         Router::connect($route);
     }
 }
开发者ID:EHER,项目名称:monopolis,代码行数:7,代码来源:RendererTest.php

示例2: tearDown

 /**
  * Clean up after the test.
  *
  * @return void
  */
 public function tearDown()
 {
     Router::connect(null);
     $this->_routes->each(function ($route) {
         Router::connect($route);
     });
     unset($this->html);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:13,代码来源:HtmlTest.php

示例3: teardown

 function teardown()
 {
     Router::reset();
     foreach ($this->_routes as $route) {
         Router::connect($route);
     }
     unset($this->analytics);
 }
开发者ID:joseym,项目名称:li3_analytics,代码行数:8,代码来源:AnalyticsTest.php

示例4: setUp

 public function setUp()
 {
     $this->html = new Html();
     $this->mock = new MockHtml();
     Router::connect('/test/{:args}', array('controller' => '\\lithium\\test\\Controller'));
     Router::connect('/test', array('controller' => '\\lithium\\test\\Controller'));
     $this->request = new Request(array('base' => null, 'env' => array('PHP_SELF' => '/', 'DOCUMENT_ROOT' => '/')));
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:8,代码来源:HtmlTest.php

示例5: setUp

 /**
  * Initialize test by creating a new object instance with a default context.
  */
 public function setUp()
 {
     Router::connect('/{:controller}/{:action}/{:args}');
     $this->request = new Request();
     $this->request->params = ['controller' => 'post', 'action' => 'index'];
     $this->request->persist = ['controller'];
     $this->context = new MockRenderer(['request' => $this->request]);
 }
开发者ID:scharrier,项目名称:li3_pagination,代码行数:11,代码来源:PaginationTest.php

示例6: testRun

 public function testRun()
 {
     Router::connect('/', array('controller' => 'test', 'action' => 'test'));
     $request = new Request();
     $request->url = '/';
     MockDispatcher::run($request);
     $result = end(MockDispatcher::$dispatched);
     $expected = array('controller' => 'test', 'action' => 'test');
     $this->assertEqual($expected, $result->params);
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:10,代码来源:DispatcherTest.php

示例7: setUp

 /**
  * Initialize test by creating a new object instance with a default context.
  */
 public function setUp()
 {
     Router::connect('/{:controller}/{:action}/{:id}.{:type}', array('id' => null));
     Router::connect('/{:controller}/{:action}/{:args}');
     $request = new Request();
     $request->params = array('controller' => 'posts', 'action' => 'index');
     $request->persist = array('controller');
     $this->context = new MockFormRenderer(compact('request'));
     $this->form = new Form(array('context' => $this->context));
     $this->base = $this->context->request()->env('base') . '/';
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:14,代码来源:FormTest.php

示例8: setUp

 public function setUp()
 {
     $this->_routes = Router::get();
     Router::reset();
     Router::connect('/{:controller}/{:action}/page/{:page:[0-9]+}');
     $request = new Request();
     $request->params = array('controller' => 'posts', 'action' => 'index');
     $request->persist = array('controller');
     $this->context = new MockRenderer(compact('request'));
     $this->pagination = new Pagination(array('context' => $this->context));
 }
开发者ID:thedisco,项目名称:li3_pagination,代码行数:11,代码来源:PaginationTest.php

示例9: testConfigManipulation

 public function testConfigManipulation()
 {
     $config = MockDispatcher::config();
     $expected = array('rules' => array());
     $this->assertEqual($expected, $config);
     MockDispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}'))));
     Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'admin_test', 'controller' => 'Test', 'admin' => true);
     $this->assertEqual($expected, $result->params);
 }
开发者ID:EHER,项目名称:monopolis,代码行数:12,代码来源:DispatcherTest.php

示例10: tearDown

 /**
  * Clean up after the test.
  */
 public function tearDown()
 {
     Router::reset();
     foreach ($this->_routes as $scope => $routes) {
         Router::scope($scope, function () use($routes) {
             foreach ($routes as $route) {
                 Router::connect($route);
             }
         });
     }
     unset($this->html);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:15,代码来源:HtmlTest.php

示例11: testUrlAutoEscaping

 /**
  * Tests that URLs are properly escaped by the URL handler.
  */
 public function testUrlAutoEscaping()
 {
     Router::connect('/{:controller}/{:action}/{:id}');
     $this->assertEqual('/<foo>/<bar>', $this->subject->url('/<foo>/<bar>'));
     $result = $this->subject->url(array('Controller::action', 'id' => '<script />'));
     $this->assertEqual('/controller/action/<script />', $result);
     $this->subject = new Simple(array('response' => new Response(), 'view' => new View(), 'request' => new Request(array('base' => '', 'env' => array('HTTP_HOST' => 'foo.local')))));
     $this->assertEqual('/&lt;foo&gt;/&lt;bar&gt;', $this->subject->url('/<foo>/<bar>'));
     $result = $this->subject->url(array('Controller::action', 'id' => '<script />'));
     $this->assertEqual('/controller/action/&lt;script /&gt;', $result);
     $result = $this->subject->url(array('Posts::index', '?' => array('foo' => 'bar', 'baz' => 'dib')));
     $this->assertEqual('/posts?foo=bar&baz=dib', $result);
 }
开发者ID:WarToaster,项目名称:HangOn,代码行数:16,代码来源:RendererTest.php

示例12: _restoreCtrlContext

 protected function _restoreCtrlContext()
 {
     Router::reset();
     foreach ($this->_context['routes'] as $scope => $routes) {
         Router::scope($scope, function () use($routes) {
             foreach ($routes as $route) {
                 Router::connect($route);
             }
         });
     }
     foreach ($this->_context['scopes'] as $scope => $attachment) {
         Router::attach($scope, $attachment);
     }
     Router::scope($this->_context['scope']);
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:15,代码来源:Controller.php

示例13: array

// TODO: See why this isn't catching in the Minerva library routes...
// This should already be set...
Router::connect('/minerva_gallery/admin/{:controller}/{:action}/{:args}', array('admin' => 'admin', 'library' => 'minerva_gallery', 'controller' => 'items', 'action' => 'index'));
// JSON Routes
Router::connect('/minerva_gallery/{:controller}/{:action}.json', array('library' => 'minerva_gallery', 'controller' => 'items', 'type' => 'json'));
Router::connect('/minerva_gallery/{:controller}/{:action}/{:args}.json', array('library' => 'minerva_gallery', 'controller' => 'items', 'type' => 'json'));
// Route for reading a gallery (note the "document_type" parameter)
Router::connect('/gallery/read/{:url}', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'read'));
// Route for listing all galleries
Router::connect('/gallery/index', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'index'));
// Pagination for galleries (default limit is 10)
Router::connect('/gallery/index/page:{:page:[0-9]+}', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'index'));
Router::connect('/gallery/index/page:{:page:[0-9]+}/limit:{:limit:[0-9]+}', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'index'));
// Yes, you can render "static" pages from the library as well by using the "view" action,
// Templates from: /libraries/minerva_gallery/views/pages/static/template-name.html.php
Router::connect('/gallery', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'view', 'home'));
Router::connect('/gallery/view/{:args}', array('library' => 'minerva', 'plugin' => 'minerva_gallery', 'controller' => 'pages', 'action' => 'view', 'home'));
// NOTE: /gallery route could also be reached via the default Minerva route: /minerva/plugin/minerva_gallery
// Also: /minerva/plugin/minerva_gallery/pages/read/document == /gallery/read/{:url}
// TODO? Do galleries also need comments? Should there be a unified comments library now?
// Router::connect('/gallery/comments/{:action}.json', array('library' => 'minerva_gallery', 'controller' => 'comments', 'type' => 'json'));
// Router::connect('/gallery/comments/{:action}/{:args}.json', array('library' => 'minerva_gallery', 'controller' => 'comments', 'type' => 'json'));
// SWEEPSTAKES LIBRARY SPECIFIC ROUTES (Routed to look like it belongs to Minerva. Library added as with 'minerva_plugin' => true, so it will follow the render paths.)
/*
Router::connect("/minerva/gallery/admin/{:controller}/{:action}/{:url}", array('admin' => 'admin', 'library' => 'sweeps', 'controller' => 'sweepstakes', 'action' => 'index'));

Router::connect("/minerva/gallery/{:controller}/{:action}", array('library' => 'sweeps', 'controller' => 'sweepstakes', 'action' => 'index'));
Router::connect("/minerva/gallery/{:controller}/{:action}/{:args}", array('library' => 'sweeps', 'controller' => 'sweepstakes', 'action' => 'index'));

Router::connect("/minerva/gallery/{:controller}/{:action}/{:url}", array('library' => 'sweeps', 'controller' => 'sweepstakes', 'action' => 'index'));
 * */
开发者ID:nateabele,项目名称:minerva_gallery,代码行数:31,代码来源:routes.php

示例14: testConfigManipulation

 public function testConfigManipulation()
 {
     $config = MockDispatcher::config();
     $expected = array('rules' => array());
     $this->assertEqual($expected, $config);
     MockDispatcher::config(array('rules' => array('admin' => array('action' => 'admin_{:action}'))));
     Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'admin_test', 'controller' => 'Test', 'admin' => true);
     $this->assertEqual($expected, $result->params);
     MockDispatcher::config(array('rules' => array('action' => array('action' => function ($params) {
         return Inflector::camelize(strtolower($params['action']), false);
     }))));
     MockDispatcher::$dispatched = array();
     Router::reset();
     Router::connect('/', array('controller' => 'test', 'action' => 'TeST-camelize'));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'testCamelize', 'controller' => 'Test');
     $this->assertEqual($expected, $result->params);
     MockDispatcher::config(array('rules' => function ($params) {
         if (isset($params['admin'])) {
             return array('special' => array('action' => 'special_{:action}'));
         }
         return array();
     }));
     MockDispatcher::$dispatched = array();
     Router::reset();
     Router::connect('/', array('controller' => 'test', 'action' => 'test', 'admin' => true));
     Router::connect('/special', array('controller' => 'test', 'action' => 'test', 'admin' => true, 'special' => true));
     MockDispatcher::run(new Request(array('url' => '/')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'test', 'controller' => 'Test', 'admin' => true);
     $this->assertEqual($expected, $result->params);
     MockDispatcher::run(new Request(array('url' => '/special')));
     $result = end(MockDispatcher::$dispatched);
     $expected = array('action' => 'special_test', 'controller' => 'Test', 'admin' => true, 'special' => true);
     $this->assertEqual($expected, $result->params);
 }
开发者ID:nilamdoc,项目名称:KYCGlobal,代码行数:40,代码来源:DispatcherTest.php

示例15: array

Router::connect('/{:library}/profile/trace/{:file}', array('file' => 'latest'), function ($request) {
    // If for some reason a profile session is active, do NOT run the code in this route.
    // It would cause some pretty big issues =)
    if (isset($_GET['XDEBUG_PROFILE']) || isset($_COOKIE['XDEBUG_PROFILE'])) {
        echo 'You can\'t attempt to get the latest profile information while the profiler is active.';
        return false;
    }
    // webgrind bootstrap/config process
    require LITHIUM_APP_PATH . '/libraries/li3_perf/extensions/webgrind/library/bootstrap.php';
    $trace_files = FileHandler::getInstance()->getTraceList(1);
    if (is_array($trace_files)) {
        $dataFile = $trace_files[0]['filename'];
        // I've seen this work before and then sometimes not...Sometimes it needs the slash. Weird.
        if (!file_exists(Webgrind::$config->xdebugOutputDir . $dataFile)) {
            $dataFile = '/' . $dataFile;
        }
        $costFormat = Webgrind::$config->defaultCostformat;
        $reader = FileHandler::getInstance()->getTraceReader($dataFile, $costFormat);
        $result = array();
        $functions = array();
        $shownTotal = 0;
        $breakdown = array('internal' => 0, 'procedural' => 0, 'class' => 0, 'include' => 0);
        $functionCount = $reader->getFunctionCount();
        $result['moodpik'] = array('function_calls' => 0, 'total_cost' => 0);
        for ($i = 0; $i < $functionCount; $i++) {
            $functionInfo = $reader->getFunctionInfo($i);
            //var_dump($functionInfo['functionName']);
            if (strstr($functionInfo['functionName'], 'moodpik\\')) {
                $result['moodpik']['function_calls']++;
                $result['moodpik']['total_cost'] += $functionInfo['summedSelfCost'];
            }
            $isInternal = strpos($functionInfo['functionName'], 'php::') !== false;
            if ($isInternal) {
                if (get('hideInternals', false)) {
                    continue;
                }
                $breakdown['internal'] += $functionInfo['summedSelfCost'];
                $humanKind = 'internal';
            } elseif (false !== strpos($functionInfo['functionName'], 'require_once::') || false !== strpos($functionInfo['functionName'], 'require::') || false !== strpos($functionInfo['functionName'], 'include_once::') || false !== strpos($functionInfo['functionName'], 'include::')) {
                $breakdown['include'] += $functionInfo['summedSelfCost'];
                $humanKind = 'include';
            } elseif (false !== strpos($functionInfo['functionName'], '->') || false !== strpos($functionInfo['functionName'], '::')) {
                $breakdown['class'] += $functionInfo['summedSelfCost'];
                $humanKind = 'class';
            } else {
                $breakdown['procedural'] += $functionInfo['summedSelfCost'];
                $humanKind = 'procedural';
            }
            $shownTotal += $functionInfo['summedSelfCost'];
            $functions[$i] = $functionInfo;
            $functions[$i]['nr'] = $i;
            $functions[$i]['humanKind'] = $humanKind;
        }
        usort($functions, 'costCmp');
        $remainingCost = $shownTotal * get('showFraction');
        $result['functions'] = array();
        foreach ($functions as $function) {
            $remainingCost -= $function['summedSelfCost'];
            $function['file'] = urlencode($function['file']);
            $result['functions'][] = $function;
            if ($remainingCost < 0) {
                break;
            }
        }
        $result['summedInvocationCount'] = $reader->getFunctionCount();
        $result['summedRunTime'] = $reader->formatCost($reader->getHeader('summary'), 'msec');
        $result['dataFile'] = $dataFile;
        $result['invokeUrl'] = $reader->getHeader('cmd');
        $result['runs'] = $reader->getHeader('runs');
        $result['breakdown'] = $breakdown;
        $result['mtime'] = date(Webgrind::$config->dateFormat, filemtime(Webgrind::$config->xdebugOutputDir . '/' . $dataFile));
        $creator = preg_replace('/[^0-9\\.]/', '', $reader->getHeader('creator'));
        $result['linkToFunctionLine'] = version_compare($creator, '2.1') > 0;
        var_dump($result);
        exit;
    }
});
开发者ID:tmaiaroto,项目名称:li3_perf,代码行数:77,代码来源:routes.php


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