• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Route类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Route的典型用法代码示例。如果您正苦于以下问题:PHP Route类的具体用法?PHP Route怎么用?PHP Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: register

 /**
  * Register a new route
  * 
  * @param string $routePattern Route pattern
  * @param \Closure $closure closure
  * 
  * @return \Chochan\Routing\Route
  */
 public function register($routePattern, \Closure $closure)
 {
     $route = new Route($this->getBaseDir() . $routePattern);
     $route->setClosure($closure);
     $this->routes[] = $route;
     return $this->routes[count($this->routes) - 1];
 }
开发者ID:g-alonso,项目名称:chochan,代码行数:15,代码来源:Router.php


示例2: __construct

 public function __construct()
 {
     $index = new Route('diensten', 'index');
     $service = new Route('%s', 'service');
     $index->add_route($service);
     $this->add_route($index);
 }
开发者ID:kidaa30,项目名称:Swevers,代码行数:7,代码来源:services.php


示例3: testRegex2

 public function testRegex2()
 {
     $expected = ['baby' => 'geza'];
     $route = new Route('/:baby', $this->matcher);
     $actual = $route->parameters('/geza');
     $this->assertEquals($expected['baby'], $actual['baby']);
 }
开发者ID:tailored-tunes,项目名称:php-router,代码行数:7,代码来源:RouteTest.php


示例4: create

 /**
  * Create the application document registry
  *
  * @param array $aData
  * @return string
  *
  */
 public function create($aData)
 {
     $oConnection = Propel::getConnection(RoutePeer::DATABASE_NAME);
     try {
         $sRouteUID = G::generateUniqueID();
         $aData['ROU_UID'] = $sRouteUID;
         $oRoute = new Route();
         // validating default values
         $aData['ROU_TO_LAST_USER'] = $this->validateValue(isset($aData['ROU_TO_LAST_USER']) ? $aData['ROU_TO_LAST_USER'] : '', array('TRUE', 'FALSE'), 'FALSE');
         $aData['ROU_OPTIONAL'] = $this->validateValue(isset($aData['ROU_OPTIONAL']) ? $aData['ROU_OPTIONAL'] : '', array('TRUE', 'FALSE'), 'FALSE');
         $aData['ROU_SEND_EMAIL'] = $this->validateValue(isset($aData['ROU_SEND_EMAIL']) ? $aData['ROU_SEND_EMAIL'] : '', array('TRUE', 'FALSE'), 'TRUE');
         $oRoute->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oRoute->validate()) {
             $oConnection->begin();
             $iResult = $oRoute->save();
             $oConnection->commit();
             return $sRouteUID;
         } else {
             $sMessage = '';
             $aValidationFailures = $oRoute->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
开发者ID:bqevin,项目名称:processmaker,代码行数:37,代码来源:Route.php


示例5: find_routes

 private function find_routes($org, $dest, &$flights)
 {
     $result = array();
     $queue = new SplPriorityQueue();
     foreach ($flights as $flight) {
         if ($flight['org_id'] == $org) {
             $route = new Route($this->route_opts);
             $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user);
             $route->add_flight($flight, $num_seats);
             $queue->insert($route, $route->get_joy());
         }
     }
     //BFS to find all routes that take < 10 hours
     $count = 0;
     while ($queue->count() > 0 && $count < $this->opts['max_results']) {
         $cur_route = $queue->extract();
         if ($cur_route->get_dest() == $dest) {
             $result[] = $cur_route;
             $count++;
             continue;
         }
         foreach ($flights as $flight) {
             if (!array_key_exists($flight['dest_id'], $cur_route->visited) && $flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) {
                 $new_route = $cur_route->copy();
                 $num_seats = Flight::get_open_seats_on_flight($flight['flight_id'], $this->user);
                 $new_route->add_flight($flight, $num_seats);
                 if ($new_route->get_trip_time() < 24 * 60 * 60 && $new_route->seats >= $this->opts['passengers']) {
                     $queue->insert($new_route, $new_route->get_joy());
                 }
             }
         }
     }
     return $result;
 }
开发者ID:NLP-Project,项目名称:GatorAirlines,代码行数:34,代码来源:search.class.php


示例6: __construct

 public function __construct()
 {
     $index = new Route('(te-koop|te-huur)', 'index');
     $detail = new Route('%s/%d', 'detail');
     $index->add_route($detail);
     $this->add_route($index);
 }
开发者ID:kidaa30,项目名称:Swevers,代码行数:7,代码来源:offer.php


示例7: find_routes

 private function find_routes($org, $dest, &$flights)
 {
     $result = array();
     $queue = new SplPriorityQueue();
     foreach ($flights as $flight) {
         if ($flight['org_id'] == $org) {
             $route = new Route($this->route_opts);
             $route->add_flight($flight);
             array_push($this->id, $flight['flight_id']);
             $queue->insert($route, $route->get_joy());
         }
     }
     //BFS to find all routes that take < 10 hours
     $count = 0;
     while ($queue->count() > 0 && $count < $this->opts['max_results']) {
         $cur_route = $queue->extract();
         if ($cur_route->get_dest() == $dest) {
             $result[] = $cur_route;
             $count++;
             continue;
         }
         foreach ($flights as $flight) {
             if ($flight['org_id'] == $cur_route->get_dest() && $flight['e_depart_time'] > 30 * 60 + $cur_route->get_arrival_time()) {
                 $new_route = $cur_route->copy();
                 $new_route->add_flight($flight);
                 array_push($this->id, $flight['flight_id']);
                 if ($new_route->get_trip_time() < 24 * 60 * 60) {
                     $queue->insert($new_route, $new_route->get_joy());
                 }
             }
         }
     }
     return $result;
 }
开发者ID:NLP-Project,项目名称:GatorAirlines,代码行数:34,代码来源:Search_F_ID.class.php


示例8: __construct

 public function __construct($modulo)
 {
     # criar uma instância do objeto de rotas
     $route = new Route();
     # carregar as rotas
     $this->setRoute($modulo, $route->initRoute());
 }
开发者ID:elsonvinicius,项目名称:huab,代码行数:7,代码来源:Bootstrap.php


示例9: load

/**
 * include and run given route 
 *
 * @param Route   $route   the route to be loaded
 * @param Request $request the request datas
 *
 * @return string the produced HTML to render
 *
 * @access public
 */
function load(Route $route, Request $request)
{
    $location = explode('::', $route->getLocation());
    include_once $location[0] . '/init.php';
    $request->addParams($route->getOptions());
    return call_user_func($location[1], $request);
}
开发者ID:jouvent,项目名称:Genitura,代码行数:17,代码来源:index.php


示例10: getDirections

 public static function getDirections(Route $route, $version = 0)
 {
     /**
      * @var DB
      */
     $dbObj = DBPool::getInstance();
     $version = $version == 0 ? TableUpdate::getVersion() : $version;
     $dbObj->bindParams(array($route->getId(), $version));
     $directions = $dbObj->get_results("SELECT * FROM direction WHERE route_id=?\n            AND version = ?");
     if ($dbObj->num_rows > 0) {
         $directionArray = array();
         foreach ($directions as $d) {
             $dirObj = new Direction();
             $dirObj->setId($d->id);
             $dirObj->setName($d->name);
             $dirObj->setPrettyName($d->pretty_name);
             $dirObj->setRoute($route);
             $dirObj->setTag($d->tag);
             $dirObj->setTitle($d->title);
             $dirObj->setPrettyTitle($d->pretty_title);
             $dirObj->setUseForUi($d->use_for_ui);
             $dirObj->setShow($d->show);
             $directionArray[$d->tag] = $dirObj;
         }
         return $directionArray;
     } else {
         //TODO: Don't use a generic exception
         throw new Exception("No data available - Direction::getDirections");
     }
 }
开发者ID:nikhilpatel1989,项目名称:Transporter-Server,代码行数:30,代码来源:Direction.php


示例11: getContent

 protected function getContent(Router $router, Context $context, Route $route)
 {
     $callback = $route->getAction();
     $values = $router->extract($context, $route);
     $bindings = $router->bind($values, $route->getBindings());
     $arguments = $router->buildArguments($callback, $bindings);
     return $callback(...$arguments);
 }
开发者ID:opis,项目名称:routing,代码行数:8,代码来源:DispatcherTrait.php


示例12: __construct

 /**
  * constructor
  *
  * @param \Naquadria\Components\Routing\Route $route
  * @param array $routeData
  * @param array $replacer
  */
 public function __construct(Route $route, array $routeData, array $replacer)
 {
     $this->name = $route->getName();
     $this->abstraction = $route->getAbstraction();
     $this->data = $routeData;
     $this->replacer = $replacer;
     $this->route = $route;
 }
开发者ID:naquadria,项目名称:routing,代码行数:15,代码来源:RouteEntity.php


示例13: dispatch

 public function dispatch(Route $route, Request $request, Response $response)
 {
     $controller = __NAMESPACE__ . '\\Controllers\\' . $route->getController();
     $action = $route->getAction();
     $foo = new $controller($request, $response);
     $foo->{$action}();
     $response->send();
 }
开发者ID:JorgePV,项目名称:FrontController,代码行数:8,代码来源:HttpDispatcher.php


示例14: copy

 public function copy()
 {
     $copy = new Route($this->opts);
     foreach ($this->flights as $flight) {
         $copy->add_flight($flight);
     }
     return $copy;
 }
开发者ID:NLP-Project,项目名称:GatorAirlines,代码行数:8,代码来源:Route_T.class.php


示例15: testMorePath

 public function testMorePath()
 {
     $route = new Route("/users/login");
     $url = parse_url("http://example.com/users/login?foo=bar");
     $this->assertInternalType("array", $route->match($url["path"], "GET", $url["host"], $url["scheme"]));
     $url = parse_url("http://example.com/users/login.php");
     $this->assertFalse($route->match($url["path"], "GET", $url["host"], $url["scheme"]));
 }
开发者ID:sugiphp,项目名称:routing,代码行数:8,代码来源:RouteMatchTest.php


示例16: testMatch

 /**
  * @dataProvider dataProviderForMatch
  */
 public function testMatch($method, $pattern, $givenMethod, $givenUri, $expectedReturn, $expectedArguments = array())
 {
     $route = new Route($method, $pattern, function () {
     });
     $this->assertEquals($expectedReturn, $route->match($givenMethod, $givenUri));
     $this->assertCount(count($expectedArguments), $route->getArguments());
     $this->assertEquals($expectedArguments, $route->getArguments());
 }
开发者ID:PierreCharles,项目名称:uFramework-PHP,代码行数:11,代码来源:RouteTest.php


示例17: build

 public static function build($name = null, $pattern, array $parameters = null)
 {
     $route = new Route();
     $route->setName($name);
     $route->setPattern($pattern);
     $route->setParameters($parameters);
     return $route;
 }
开发者ID:marcelsud,项目名称:melody-router,代码行数:8,代码来源:RouteFactory.php


示例18: testInvoke_Failing

 public function testInvoke_Failing()
 {
     $route = new Route();
     $route->setAction('sample');
     $controller = $this->createController();
     $this->setExpectedException('NotFoundHttpException');
     $this->object->invoke($controller, $route);
 }
开发者ID:juraj-blahunka,项目名称:Bachelor-Thesis,代码行数:8,代码来源:ControllerActionInvokerTest.php


示例19: hydrate

 public function hydrate(array $data = [])
 {
     foreach ($data as $value) {
         $intervention = new Route();
         $intervention->hydrate($value);
         $this[] = $intervention;
     }
 }
开发者ID:bixev,项目名称:intervention-sdk,代码行数:8,代码来源:Routes.php


示例20: add

 /**
  * Adds a new route context to the routing table.
  *
  * @param Route $route
  *
  * @throws RouteIdentifierException
  */
 public function add(Route $route)
 {
     $identifier = $route->identifier();
     if (isset($this->routes[$identifier])) {
         throw new RouteIdentifierException("Cannot redeclare route identified by: {$identifier}");
     }
     $this->routes[$identifier] = $route;
 }
开发者ID:Trivivium,项目名称:Hydro,代码行数:15,代码来源:Collection.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Router类代码示例发布时间:2022-05-23
下一篇:
PHP Root_Controller类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap