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


PHP Route类代码示例

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


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


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