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

PHP core\Router类代码示例

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

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



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

示例1: run

 public function run()
 {
     $iID = $this->post('id');
     $iAccountID = $this->post('account_id');
     (new m\Account())->del($iID);
     c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID]));
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:7,代码来源:DeleteField.php


示例2: start

 /**
  * 启动程序
  * @return [type] [description]
  */
 public function start()
 {
     $this->init();
     //数据库初使化
     DB::init();
     //路由初使化
     Router::init();
     //TODO:: 还需要支持自定义的路由
     if (file_exists(APP_PATH . 'config/Router.php')) {
     }
     //调用控制器
     $controllerFile = APP_PATH . MODULE . 'controller/' . CONTROLLER . CLASS_EXT;
     if (file_exists($controllerFile)) {
         include_once $controllerFile;
         $controller = MODULE ? MODULE : "Controller" . '\\' . CONTROLLER;
         $action = ACTION;
         $obj = new $controller();
         if (method_exists($obj, $action)) {
             $obj->{$action}();
         } else {
             throw new \Exception("非法操作: " . ACTION);
         }
     } else {
         throw new \Exception("无法加载控制器: " . CONTROLLER);
     }
 }
开发者ID:AimuTran,项目名称:iChat,代码行数:30,代码来源:App.class.php


示例3: run

 public function run()
 {
     $iAccountID = $this->get('id');
     $oAccount = new m\Account();
     $aDetail = $oAccount->getAccountDetail($iAccountID);
     if (empty($aDetail)) {
         c\Router::redirect(c\Router::genURL('Home'));
     }
     $aFields = $oAccount->getAccountFields($iAccountID);
     $oUser = new m\User();
     $aDefaultPassword = $oUser->getDefaultPassword();
     $aEmails = $oUser->getEmails();
     foreach ($aFields as $k => $v) {
         $aFields[$k]['display'] = u\Str::partCover($v['value'], 2, 1);
     }
     sort($aFields);
     $aFieldNames = array_map(function ($v) {
         foreach ($v as $key => $value) {
             if ($key !== 'name') {
                 unset($v[$key]);
             }
         }
         return $v;
     }, $aFields);
     $aAccountAll = $oAccount->getAllAccount();
     $aSiteList = [];
     foreach ($aAccountAll as $aAccountDetail) {
         $aSiteList[] = ['name' => 'link:' . $aAccountDetail['name']];
     }
     $aData = ['page_title' => 'Open Sesame - ' . $aDetail['name'], 'app' => $aDetail, 'fields' => $aFields, 'form_action_add' => c\Router::genURL('AddField'), 'form_action_del' => c\Router::genURL('DeleteField'), 'form_action_updatefield' => c\Router::genURL('UpdateField'), 'form_action_updateaccount' => c\Router::genURL('UpdateAccount'), 'site_list' => json_encode($aSiteList), 'field_names' => json_encode($aFieldNames), 'default_password' => $aDefaultPassword['data'], 'emails' => $aEmails['data']];
     return $aData;
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:32,代码来源:Detail.php


示例4: redirect

 /**
  *Redirect
  **/
 public function redirect($url, $code = null)
 {
     if ($code == 301) {
         header("HTTP/1.1 301 Moved Permanently");
     }
     header("location: " . Router::url($url));
 }
开发者ID:EquipeK,项目名称:Extranet,代码行数:10,代码来源:Controller.php


示例5: run

 public function run()
 {
     error_reporting(Config::get('app.debug') ? E_ALL : 0);
     //Set Date Timezone
     date_default_timezone_set(Config::get('app.timezone'));
     //Set Cache Ctatus
     ini_set('opcache.revalidate_freq', Config::get('app.cache') ? '0' : '1');
     try {
         static::stripTraillingSlash();
         $this->session->start();
         Router::init();
         $routerParams = Router::getParams();
         $this->handleMiddlewares($routerParams);
         $controllerParams = [];
         foreach ($routerParams as $paramName => $paramValue) {
             if (substr($paramName, 0, 1) != '_') {
                 $controllerParams[$paramName] = $paramValue;
             }
         }
         if (isset($routerParams['_params']) && is_array($routerParams['_params'])) {
             foreach ($routerParams['_params'] as $paramName => $paramValue) {
                 $controllerParams[$paramName] = $paramValue;
             }
         }
         $controllerFullName = '\\App\\Controllers\\' . $routerParams['_controller'];
         try {
             return $this->di->call($controllerFullName . '::' . $routerParams['_method'], $controllerParams);
         } catch (Exception $e) {
             new ExceptionHandler($e);
         }
     } catch (Exception $e) {
         new ExceptionHandler($e);
     }
     return true;
 }
开发者ID:sikamy,项目名称:sephy-framework,代码行数:35,代码来源:Application.php


示例6: run

 public function run($config)
 {
     $this->extr($config);
     //раскручиваем конфиг
     Router::init()->run();
     //вызываем роутер
 }
开发者ID:kunaksergey,项目名称:shop,代码行数:7,代码来源:App.php


示例7: __construct

 public function __construct()
 {
     $app = App::getInstance();
     // On initialise l'objet Request
     if ($_ENV['USE_ROUTES']) {
         require '../Config/routes.php';
         $this->request = Router::run(new Request($app));
     } else {
         $this->request = new Request($app);
     }
     // On parse l'url (définition du controller, action,...)
     Router::parse($this->request);
     // On affiche les erreurs ?
     Debug::set();
     // On charge le bon controller
     try {
         $controller = $this->loadController();
     } catch (SwithException $e) {
         (new SwithError(['message' => "Le controller {$this->request->controller} est introuvable", "title" => "Controlleur introuvable"]))->display();
     }
     if (method_exists($controller, "beforeRender")) {
         $controller->beforeRender();
     }
     // On appelle la fonction
     $action = $this->request->getAction();
     $availablesActions = array_diff(get_class_methods($controller), get_class_methods(get_parent_class($controller)));
     if (in_array($action, $availablesActions)) {
         call_user_func_array([$controller, $action], $this->request->params);
     } else {
         (new SwithError(['message' => "Le controller {$this->request->controller} n'a pas de methode {$action}", "title" => "Methode introuvable"]))->display();
     }
     $controller->render($controller->view);
 }
开发者ID:kranack,项目名称:swithMVC,代码行数:33,代码来源:Dispatcher.php


示例8: routes

 /**
  * Routes for this Members Module
  */
 public function routes()
 {
     Router::any('members', 'Modules\\Members\\Controllers\\Members@members');
     Router::any('online-members', 'Modules\\Members\\Controllers\\Members@online');
     Router::any('profile/(:any)', 'Modules\\Members\\Controllers\\Members@viewProfile');
     Router::any('edit-profile', 'Modules\\Members\\Controllers\\Members@editProfile');
 }
开发者ID:BryanYeh,项目名称:apple-pie,代码行数:10,代码来源:Members.php


示例9: run

 public function run()
 {
     $sFieldName = $this->post('field_name');
     $sFieldValue = $this->post('field_value');
     $iAccountID = $this->post('account_id');
     (new m\Account())->addField($sFieldName, $sFieldValue, $iAccountID);
     c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID]));
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:8,代码来源:AddField.php


示例10: run

 public function run()
 {
     $sAccountName = $this->post('account_name');
     $sAccountURL = 'http://' . parse_url($this->post('account_url'))['host'];
     $iAccountID = $this->post('account_id');
     (new m\Account())->updateAccount($sAccountName, parse_url($sAccountURL)['host'], $iAccountID, false);
     c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID]));
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:8,代码来源:UpdateAccount.php


示例11: run

 public function run()
 {
     $sName = $this->post('name');
     $sURL = $this->post('url');
     $aURLDetail = parse_url($sURL);
     $iAccountID = (new m\Account())->addAccount($sName, $aURLDetail['host']);
     c\Router::redirect(c\Router::genURL('Detail', ['id' => $iAccountID]));
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:8,代码来源:AddAccount.php


示例12: routes

 public function routes()
 {
     Router::any('AdminPanel', 'Modules\\AdminPanel\\Controllers\\AdminPanel@dashboard');
     Router::any('AdminPanel-Users', 'Modules\\AdminPanel\\Controllers\\AdminPanel@users');
     Router::any('AdminPanel-User/(:any)', 'Modules\\AdminPanel\\Controllers\\AdminPanel@user');
     Router::any('AdminPanel-Groups', 'Modules\\AdminPanel\\Controllers\\AdminPanel@groups');
     Router::any('AdminPanel-Group/(:any)', 'Modules\\AdminPanel\\Controllers\\AdminPanel@group');
 }
开发者ID:BryanYeh,项目名称:UserApplePie-v-2,代码行数:8,代码来源:AdminPanel.php


示例13: routes

 public function routes()
 {
     Router::any('Profile/(:any)', 'Modules\\Profile\\Controllers\\Profile@viewprofile');
     Router::any('Profile', 'Modules\\Profile\\Controllers\\Profile@viewprofile_error');
     Router::any('Profile_Error', 'Modules\\Profile\\Controllers\\Profile@viewprofile_error');
     Router::any('Profile_Error/(:any)', 'Modules\\Profile\\Controllers\\Profile@viewprofile_error');
     Router::any('EditProfile', 'Modules\\Profile\\Controllers\\Profile@profile_edit');
     Router::any('PrivacySettings', 'Modules\\Profile\\Controllers\\Profile@privacy_settings');
 }
开发者ID:gitter-badger,项目名称:UserApplePie-v-2,代码行数:9,代码来源:Profile.php


示例14: nested

 public static function nested($class, $offset = 1)
 {
     if (!isset(\Core\Router::$uriParts[$offset])) {
         return;
     }
     $next = \Core\Router::$uriParts[$offset];
     $parts = array_slice(explode('\\', $class), 1);
     $path = strtolower(implode(DIRECTORY_SEPARATOR, $parts));
     \Core\Router::controller($path, $next);
 }
开发者ID:rlaskey,项目名称:dm-track,代码行数:10,代码来源:controller.php


示例15: run

 public function run()
 {
     $oAccount = new m\Account();
     $iTotal = $oAccount->getTotal();
     if ($iTotal === false) {
         $oAccount->createTable();
     }
     $aData = ['page_title' => 'Open Sesame', 'form_action_add' => c\Router::genURL('AddAccount'), 'site_total' => $iTotal, 'recomm' => (new m\Recommand())->get(4)];
     return $aData;
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:10,代码来源:Home.php


示例16: add

 /**
  * Add assets to load
  * 
  * @param string|array $name
  * @param string $type
  */
 public static function add($name, $type)
 {
     if (!self::$router instanceof Router) {
         trigger_error('Set a instance of Router', E_USER_ERROR);
         return;
     }
     if (!is_array($name)) {
         $name = array($name);
     }
     foreach ($name as $once) {
         if (!isset(self::$toLoad[$type][$once])) {
             $assetUrl = self::$router->getAssetUrl($once, $type);
             if (!empty($assetUrl)) {
                 self::$toLoad[$type][$once] = $assetUrl;
             } else {
                 trigger_error('Generate asset url unsuccessful for ' . $once);
             }
         }
     }
 }
开发者ID:stefanak-michal,项目名称:DragonMVC,代码行数:26,代码来源:Assets.php


示例17: routes

 public function routes()
 {
     Router::any('Messages', 'Modules\\Messages\\Controllers\\Messages@messages');
     Router::any('ViewMessage/(:any)', 'Modules\\Messages\\Controllers\\Messages@view');
     Router::any('MessagesInbox', 'Modules\\Messages\\Controllers\\Messages@inbox');
     Router::any('MessagesInbox/(:any)', 'Modules\\Messages\\Controllers\\Messages@inbox');
     Router::any('MessagesOutbox', 'Modules\\Messages\\Controllers\\Messages@outbox');
     Router::any('MessagesOutbox/(:any)', 'Modules\\Messages\\Controllers\\Messages@outbox');
     Router::any('NewMessage', 'Modules\\Messages\\Controllers\\Messages@newmessage');
     Router::any('NewMessage/(:any)', 'Modules\\Messages\\Controllers\\Messages@newmessage');
 }
开发者ID:davarravad,项目名称:UserApplePie-v-2,代码行数:11,代码来源:Messages.php


示例18: run

 public function run()
 {
     $sKeyword = $this->get('q');
     $aList = (new m\Search())->handle($sKeyword);
     $aOutput = [];
     foreach ($aList as $aAccount) {
         $aOutput[] = ['name' => $aAccount['name'], 'rowid' => $aAccount['rowid'], 'info_url' => c\Router::genURL('Detail', ['id' => $aAccount['rowid']]), 'goto_url' => $aAccount['value']];
     }
     $aData = ['page_title' => '搜索结果', 'keyword' => $sKeyword, 'total' => count($aList), 'form_action_del' => c\Router::genURL('DeleteAccount'), 'site_list' => $aOutput];
     return $aData;
 }
开发者ID:sdgdsffdsfff,项目名称:open-sesame,代码行数:11,代码来源:Search.php


示例19: routes

 public function routes()
 {
     // Check to make sure Forum is Enabled, otherwise hide it
     if ($this->forum_on_off == 'Enabled') {
         Router::any('Forum', 'Modules\\Forum\\Controllers\\Forum@forum');
         Router::any('Topics/(:num)', 'Modules\\Forum\\Controllers\\Forum@topics');
         Router::any('Topics/(:num)/(:num)', 'Modules\\Forum\\Controllers\\Forum@topics');
         Router::any('Topic/(:num)', 'Modules\\Forum\\Controllers\\Forum@topic');
         Router::any('Topic/(:num)/(:num)', 'Modules\\Forum\\Controllers\\Forum@topic');
         Router::any('NewTopic/(:num)', 'Modules\\Forum\\Controllers\\Forum@newtopic');
     }
 }
开发者ID:davarravad,项目名称:UserApplePie-v-2,代码行数:12,代码来源:Forum.php


示例20: testFindUrl

 public function testFindUrl()
 {
     $r = new Router($this->container);
     $r->addRoute('a/b', 'controller1', 'action1');
     $r->addRoute('a/:myvar1/b/:myvar2', 'controller2', 'action2', array('myvar1', 'myvar2'));
     $this->assertEquals('a/1/b/2', $r->findUrl('controller2', 'action2', array('myvar1' => 1, 'myvar2' => 2)));
     $this->assertEquals('', $r->findUrl('controller2', 'action2', array('myvar1' => 1)));
     $this->assertEquals('a/b', $r->findUrl('controller1', 'action1'));
     $this->assertEquals('', $r->findUrl('controller1', 'action2'));
 }
开发者ID:redarrow,项目名称:kanboard,代码行数:10,代码来源:RouterTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP core\Security类代码示例发布时间:2022-05-23
下一篇:
PHP core\Model类代码示例发布时间: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