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


PHP Router::getRoute方法代码示例

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


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

示例1: getController

 public function getController()
 {
     $router = new Router();
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../../App/' . $this->name . '/Config/route.xml');
     $routes = $xml->getElementByTagName("route");
     foreach ($routes as $route) {
         $vars = [];
         if ($route->hasAttribute('vars')) {
             $vars = explode(',', $route->getAttribute('vars'));
         }
         $router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars));
     }
     try {
         $matched_route = $router->getRoute($this->httpRequest->requestURI());
     } catch (\RuntimeException $exception) {
         if ($exception->getCode() == Router::NO_ROUTE) {
             $this->httpResponse->redirect404();
         }
     }
     // Add variables in tab: $_GET
     $_GET = array_merge($_GET, $matched_route->module(), $matched_route->action());
     // Instancie the controller
     $controller_class = 'App\\' . $this->name . '\\Modules\\' . $matched_route->module() . '\\' . $matched_route->module() . 'Controllers';
     return new $controller_class($this, $matched_route->module(), $matched_route->action());
 }
开发者ID:rainevincent,项目名称:MyFramework,代码行数:26,代码来源:Application.php

示例2: generateResponse

 public function generateResponse($route = null, $params = array(), $internal = false)
 {
     $router = new Router();
     $request = Request::getInstance();
     $request->setInternal($internal);
     if ($route) {
         $route = $router->getRoute($route);
     } else {
         $route = $router->getDefaultRoute();
     }
     $controller = $route->getController();
     $action = $route->getAction();
     $controller = new $controller();
     $r = new ReflectionMethod($controller, $action);
     $paramsOfFunction = $r->getParameters();
     $paramsToPass = array();
     $indexParams = 0;
     foreach ($paramsOfFunction as $param) {
         if ($param->getClass() != NULL && $param->getClass()->getName() == 'Request') {
             $paramsToPass[] = $request;
         } else {
             if (isset($params[$indexParams])) {
                 $paramsToPass[] = $params[$indexParams++];
             } else {
                 $paramsToPass[] = null;
             }
         }
     }
     if (!empty($paramsToPass)) {
         return call_user_func_array(array($controller, $action), $paramsToPass);
     }
     return $controller->{$action}();
 }
开发者ID:alexandre-le-borgne,项目名称:-PHP-DUT-S3-Projet,代码行数:33,代码来源:Kernel.php

示例3: beforeAction

 public function beforeAction()
 {
     // auto find model entry when id passed
     if (isset($this->params['id'])) {
         if (!$this->{$this->name}->fromId($this->params['id'])) {
             return false;
         }
         $this->data->set($this->name, $this->{$this->name});
     }
     // send invalid logins (invalid user group) back to loing page
     if (!$this->UserLogin->loggedin() && empty($this->publicActions)) {
         $this->redirect(Router::getRoute('adminLogin'));
     }
     // change language on users locale
     if (isset($this->I18n) && $this->UserLogin->loggedin() && $this->User->hasField('locale')) {
         $this->I18n->locale($this->UserLogin->User->locale);
     }
     // if mobile layout selected, use other action view files
     if ($this->layout == 'mobile') {
         // and increase number of returned model entries
         if (!empty($this->{$this->name})) {
             $this->{$this->name}->perPage = 50;
             if (!in_array($this->action, array('edit', 'view'))) {
                 $this->{$this->name}->depth = 0;
             }
         }
         $this->action .= '.mobile';
     }
     return parent::beforeAction();
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:30,代码来源:AdminController.php

示例4: getController

 public function getController()
 {
     $Router = new Router();
     $this->Router = $Router;
     $xml = new \DOMDocument();
     $xml->load(__DIR__ . '/../../App/' . $this->name . '/Config/routes.xml');
     $routes = $xml->getElementsByTagName('route');
     // On parcourt les routes du fichier XML.
     foreach ($routes as $route) {
         $vars = [];
         // On regarde si des variables sont présentes dans l'URL.
         if ($route->hasAttribute('vars')) {
             $vars = explode(',', $route->getAttribute('vars'));
         }
         // On ajoute la route au routeur.
         $Router->addRoute(new Route($route->getAttribute('url'), $route->getAttribute('module'), $route->getAttribute('action'), $vars));
     }
     try {
         // On récupère la route correspondante à l'URL.
         $matchedRoute = $Router->getRoute($this->httpRequest->requestURI());
     } catch (\RuntimeException $e) {
         if ($e->getCode() == Router::NO_ROUTE) {
             // Si aucune route ne correspond, c'est que la page demandée n'existe pas.
             $this->httpResponse->redirect404();
         }
     }
     // On ajoute les variables de l'URL au tableau $_GET.
     $_GET = array_merge($_GET, $matchedRoute->vars());
     // On instancie le contrôleur.
     $controllerClass = 'App\\' . $this->name . '\\Modules\\' . $matchedRoute->module() . '\\' . $matchedRoute->module() . 'Controller';
     return new $controllerClass($this, $matchedRoute->module(), $matchedRoute->action());
 }
开发者ID:shibiro,项目名称:Melody,代码行数:32,代码来源:Application.php

示例5: ajaxSearch

 public function ajaxSearch()
 {
     $search = $_GET['s'];
     $groups = $this->group->getGroupInfoByName($search);
     $sports = $this->acc->getSportsByName($search);
     $users = $this->acc->getUsersByName($search);
     echo json_encode(["groupe" => array_slice($groups, 0, 5), "urlgroupe" => $_GET['lang'] . "/" . Router::getRoute('groupe'), "sports" => array_slice($sports, 0, 5), "urlsport" => $_GET['lang'] . "/" . Router::getRoute('SportGroupe'), "users" => array_slice($users, 0, 5)]);
 }
开发者ID:GuillaumeCa,项目名称:Dynamo,代码行数:8,代码来源:AccueilController.php

示例6: __construct

 /**
  *
  */
 public function __construct()
 {
     $this->View = View::getInstance();
     $this->Model = Router::getRoute()['Controller'];
     $this->loadModel($this->Model);
     $this->Request = Request::getInstance();
     $this->Session = Session::getInstance();
     Orm::getInstance();
 }
开发者ID:NuBOXDevCom,项目名称:frambox-core,代码行数:12,代码来源:Controller.php

示例7: delete

 /**
  * Delete single {@link UserGroup}
  * 
  * @param integer $id
  * @return boolean
  */
 public function delete($id = null)
 {
     if ($this->UserGroup->delete()) {
         $this->FlashMessage->set(__('Die Benutzergruppe <q>:1</q> wurder erfolgreich gelöscht.', $this->UserGroup->get('name')), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Es ist ein Fehler beim Löschen der Benutzergruppe aufgetreten.'), FlashMessageType::ERROR);
     }
     return $this->redirect(Router::getRoute('adminScaffold', array('controller' => $this->name)));
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:15,代码来源:AdminUserGroupController.php

示例8: delete

 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->FlashMessage->set(__('Blogeintrag erfolgreich gelöscht.'), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen des Blogeintrags.'), FlashMessageType::ERROR);
     }
     $this->redirect(Router::getRoute('adminBlogPost'));
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:9,代码来源:AdminBlogPostController.php

示例9: delete

 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->FlashMessage->set(__('Zugriffsrecht erfolgreich gelöscht.'), FlashMessageType::SUCCESS);
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen des Zugriffsrecht.'), FlashMessageType::ERROR);
     }
     $this->redirect(Router::getRoute('adminScaffold', array('controller' => $this->name)));
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:9,代码来源:AdminPermissionController.php

示例10: delete

 public function delete($id = null)
 {
     if (parent::delete($id)) {
         $this->MediaFile->updateWhere(array('folder_id' => (int) $id), array('folder_id' => 'NULL'));
         $this->FlashMessage->set(__('Die Kategorie wurde erfolgreich gelöscht. Dateien die in dieser Kategorie waren sind nun nicht mehr zugeordnet'));
     } else {
         $this->FlashMessage->set(__('Fehler beim Löschen der Kategorie'));
     }
     $this->redirect(Router::getRoute('adminMediaFiles'));
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:10,代码来源:AdminFolderController.php

示例11: run

 public function run(Query $config)
 {
     // Set the timezone for the user using the system one
     Utils::defineTimeZone();
     // Retrieve the route from the given parameters
     $route = Router::getRoute($config);
     if ($route !== false) {
         $this->invoke($route);
     }
 }
开发者ID:jessefurmanek,项目名称:dotfiles,代码行数:10,代码来源:Bootstrap.php

示例12: parseRequest

 public function parseRequest()
 {
     if (isset($_SERVER['REDIRECT_URL']) && !empty($_SERVER['REDIRECT_URL'])) {
         $url = $_SERVER['REDIRECT_URL'];
     } else {
         $url = $_SERVER['REQUEST_URI'];
     }
     list($handler, $args) = Router::getRoute($url);
     return array($handler, $args);
 }
开发者ID:davemcphee,项目名称:AustinDecoded,代码行数:10,代码来源:class.MasterController.inc.php

示例13: detailPageUri

 /**
  * Return uri-string to a single blog entry
  */
 public function detailPageUri(array $params = array())
 {
     if (!$this->exists()) {
         return false;
     }
     if ($this->isEmpty('uri')) {
         return Router::getRoute('blogEntryId', array('id' => $this->id));
     } else {
         return Router::getRoute('blogEntryUri', array('uri' => $this->uri));
     }
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:14,代码来源:BlogPost.php

示例14: adminDetailPageUri

 /**
  *	Uses the router and the name of the model to return a detail page
  *	uri that leads to the detail page of of a model entry
  *	@param array(string) $additionalParams
  *	@return string
  */
 public function adminDetailPageUri($additionalParams = array())
 {
     if (!is_array($additionalParams)) {
         $additionalParams = array('action' => $additionalParams);
     }
     $params = array_merge(array('action' => '', 'id' => $this->id, 'controller' => $this->name), $additionalParams);
     $uri = Router::getRoute('admin' . String::ucFirst($this->name) . 'Id', $params);
     if (empty($uri)) {
         $uri = Router::getRoute('adminScaffoldId', $params);
     }
     return $uri;
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:18,代码来源:AppModel.php

示例15: create

 public function create()
 {
     $this->data->set('pageTitle', __('Sprache erstellen'));
     if ($this->AdminLanguageForm->ok()) {
         $this->AdminLanguageForm->toModel($this->Language);
         if (!$this->Language->save()) {
             $this->AdminLanguageForm->errors = $this->Language->validationErrors;
         } else {
             $this->FlashMessage->set(__('Die neue Sprache wurde erfolgreich angelegt.'), FlashMessageType::HINT);
             $this->redirect(Router::getRoute('adminLanguage'));
         }
     }
 }
开发者ID:Ephigenia,项目名称:harrison,代码行数:13,代码来源:AdminLanguageController.php


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