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


PHP Route::getController方法代码示例

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


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

示例1: 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

示例2: __construct

 public function __construct()
 {
     self::$__instance = $this;
     set_exception_handler('exceptionHandler');
     // setup our loader instance
     $this->loader = new Loader();
     // load a few helpers
     $this->loader->helper('uri', FRAMEWORK_PATH . 'helpers');
     // loader the plugins
     $this->plugins = $this->loader->manager('plugins');
     $this->plugins->loadFrameworkPlugins();
     // what shall we load first?
     $this->route = $this->loader->manager('route')->find();
     // load the controller
     $this->controller = $this->loader->controller($this->route->getController());
     $this->controller->invokeAction($this->route->getAction());
 }
开发者ID:TheProjecter,项目名称:scratch-framework,代码行数:17,代码来源:scratch.php

示例3: __construct

 /**
  * @param Route $route The unparsed route whose properties we are copying
  */
 public function __construct(Route $route)
 {
     parent::__construct($route->getMethods(), $route->getRawPath(), $route->getController());
     $this->setName($route->getName());
     $this->setRawHost($route->getRawHost());
     $this->addMiddleware($route->getMiddleware());
     $this->setSecure($route->isSecure());
     $this->setVarRegexes($route->varRegexes);
 }
开发者ID:scaleddynamics,项目名称:Opulence,代码行数:12,代码来源:ParsedRoute.php

示例4: __construct

 /**
  * __construct()
  * check if init() method is declared and runs
  *
  * @see \ngfw\Route
  * @see \ngfw\View
  */
 public function __construct()
 {
     $className = Route::getController();
     $method = Route::getAction();
     $this->view = new View($className, $method);
     if (method_exists($this, 'init')) {
         $this->init();
     }
 }
开发者ID:ngfw,项目名称:framework,代码行数:16,代码来源:Controller.php

示例5: testGetSet

 /**
  * @dataProvider getSetProvider
  * @covers Route::getController
  * @covers Route::setController
  * @covers Route::getAction
  * @covers Route::setAction
  * @covers Route::getParams
  * @covers Route::setParams
  *
  * @param string $controller
  * @param string $action
  * @param array $params
  */
 public function testGetSet($controller, $action, array $params)
 {
     $route = new Route('a', 'b', array('c'));
     $route->setController($controller);
     $this->assertEquals($controller, $route->getController());
     $route->setAction($action);
     $this->assertEquals($action, $route->getAction());
     $route->setParams($params);
     $this->assertEquals($params, $route->getParams());
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:23,代码来源:RouteTest.php

示例6: getLink

 /**
  * The function returns current controller link.
  * If passed link starts from / returns related to root controller.
  * 
  * @access protected
  * @param string $link The part of link.
  * @param bool $restoreGet If TRUE returns link with GET parameters.
  * @return string The link.
  */
 protected function getLink($link = '', $restoreGet = false)
 {
     $Controller = $this->getController();
     if (substr($link, 0, 1) == '/') {
         $Controller = Route::getController('/');
     }
     if ($link) {
         $link = '/' . ltrim($link, '/');
     }
     if ($restoreGet && count($_GET)) {
         $link .= strpos($link, '?') === false ? '?' : '&';
         $link .= http_build_query($_GET);
     }
     return rtrim(_L($Controller), '/') . $link;
 }
开发者ID:vosaan,项目名称:ankor.local,代码行数:24,代码来源:base.php

示例7: invoke

 private function invoke(Route $route)
 {
     $className = 'AlfredSlack\\Controllers\\' . ucfirst($route->getController()) . 'Controller';
     $actionName = $route->getAction() . 'Action';
     $controller = new $className();
     if (!$controller instanceof \AlfredSlack\Controllers\Controller) {
         throw new \Exception("{$className} must inherits from AlfredSlack\\Controllers\\Controller");
     }
     Utils::log('ACTION: ' . $className . '::' . $actionName . '()');
     Utils::log('SIMULATE: php -r \'$query="' . str_replace('"', '\\"', json_encode($route)) . '";include "scripts/index.php";\';');
     $interruptAction = $controller->preDispatch($actionName, $route->getParams()) === false;
     if (!$interruptAction) {
         $actionResult = $controller->dispatch($actionName, $route->getParams());
         $controller->postDispatch($actionName, $route->getParams(), $actionResult);
     }
 }
开发者ID:jessefurmanek,项目名称:dotfiles,代码行数:16,代码来源:Bootstrap.php

示例8: processRoute

 /**
  * @param array      $routeConfig
  * @param Route|null $parentRoute
  *
  * @return Route
  */
 private function processRoute(array $routeConfig, Route $parentRoute = null)
 {
     $name = $routeConfig['name'];
     $url = isset($routeConfig['options']['route']) ? $routeConfig['options']['route'] : '';
     $controller = isset($routeConfig['options']['defaults']['controller']) ? $routeConfig['options']['defaults']['controller'] : null;
     $action = isset($routeConfig['options']['defaults']['action']) ? $routeConfig['options']['defaults']['action'] : null;
     if (null !== $parentRoute) {
         $name = $parentRoute->getName() . '/' . $name;
         $url = $parentRoute->getUrl() . $url;
         if (null === $controller) {
             $controller = $parentRoute->getController();
         }
     }
     if (null === $action) {
         $action = 'index';
     }
     $action .= 'Action';
     return new Route($name, $url, $controller, $action);
 }
开发者ID:noiselabs,项目名称:zf-debug-utils,代码行数:25,代码来源:RouteCollectionBuilder.php

示例9: loadController

 /**
  * _loadController()
  * Loads application controller
  *
  * @see \ngfw\Route
  * @throws \ngfw\Exception
  * @return void
  */
 private function loadController()
 {
     if (!$this->_controllerLoaded) {
         $controllerTitle = Route::getController() . "Controller";
         if (class_exists($controllerTitle)) {
             $this->_controllerObject = new $controllerTitle();
         } else {
             throw new Exception(sprintf('The requested Controller "%s" does not exist.', $controllerTitle));
         }
         if ($this->_viewTemplate) {
             $this->_controllerObject->setViewObject("template", $this->_viewTemplate);
         }
         $this->_controllerLoaded = true;
         $method = Route::getAction() . "Action";
         if (is_callable(array($this->_controllerObject, $method))) {
             call_user_func(array($this->_controllerObject, $method));
             $this->_controllerObject->startRander();
         } else {
             throw new Exception(sprintf('The requested method "%s" does not exist in %s.', $method, $controllerTitle));
         }
     }
 }
开发者ID:ngfw,项目名称:framework,代码行数:30,代码来源:Bootstrap.php

示例10: getControllerName

 /**
  * Return current controller name
  *
  * @static
  * @access   public
  * @return   string
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public static function getControllerName()
 {
     return static::$currentRoute->getController();
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:13,代码来源:Router.php

示例11: initRoute

 /**
  * The function initializes router feature.
  * 
  * @static
  * @access private
  */
 private static function initRoute()
 {
     Route::run(Request::get('REQUEST_URI', '/', 'SERVER'));
     $host = strtolower(Config::get('host'));
     if ($host) {
         $sub = trim(str_replace($host, '', preg_replace('/^www\\./', '', strtolower(Runtime::get('HTTP_HOST')))), '.');
         if (!$sub) {
             $sub = 'www';
         }
         Runtime::set('HTTP_SUBDOMAIN', $sub);
     }
     $controller = 0;
     $args = array();
     $path = Route::get();
     Runtime::set('REQUEST_URI', '/' . implode('/', $path));
     if (!is_array($path)) {
         $path = ltrim('/', explode('/', $path));
     }
     $values = $path;
     $link = '/';
     for ($i = 0; $i < count($values); $i++) {
         $arr = array_slice($values, 0, count($values) - $i);
         $link = '/' . implode('/', $arr);
         $controller = Route::getController($link);
         if ($controller) {
             $args = array_slice($values, count($values) - $i);
             break;
         }
     }
     if (!$controller) {
         $controller = Route::getController('/');
         $args = $values;
     }
     if (!$controller) {
         echo "No controller found: /" . implode('/', $path) . "\n";
         exit;
     }
     Runtime::set('ROUTING_CONTROLLER', $controller);
     Runtime::set('ROUTING_ROUTER', Route::getRouter($link));
     Runtime::set('ROUTING_ARGUMENTS', $args);
 }
开发者ID:vosaan,项目名称:ankor.local,代码行数:47,代码来源:application.php

示例12: run

 /**
  * Run application
  *
  * @staticvar boolean $is_init
  * @staticvar array $routes
  * @param $route (optional, ex: 'my/route->action')
  * @return void
  */
 public function run($route = null)
 {
     static $is_init = false;
     static $routes = [];
     // routes stack for current request
     if (!$is_init) {
         $this->log->trace('Initializing', Logger::CATEGORY_DRONE);
         // param default values
         $default = [self::KEY_DEBUG => true, self::KEY_ERROR_BACKTRACE => true, self::KEY_ERROR_HANDLER => ['\\Drone\\Core', 'errorHandler'], self::KEY_ERROR_LOG => false, self::KEY_EXT_TEMPLATE => '.tpl', self::KEY_EXT_WEB => '.htm', self::KEY_PATH_CONTROLLER => PATH_ROOT . '_app/mod', self::KEY_PATH_TEMPLATE => PATH_ROOT . '_app/tpl', self::KEY_PATH_TEMPLATE_GLOBAL => PATH_ROOT . '_app/tpl/_global'];
         // init param default values
         foreach ($default as $k => $v) {
             if (!Registry::has($k)) {
                 Registry::set($k, $v);
             }
         }
         // set default error handler
         if (is_array(Registry::get(self::KEY_ERROR_HANDLER))) {
             set_error_handler(Registry::get(self::KEY_ERROR_HANDLER));
         }
         // init paths
         $this->__formatDir(Registry::get(self::KEY_PATH_CONTROLLER));
         $this->__formatDir(Registry::get(self::KEY_PATH_TEMPLATE));
         $this->__formatDir(Registry::get(self::KEY_PATH_TEMPLATE_GLOBAL));
         $is_init = true;
     }
     Registry::set(self::KEY_ROUTE_CONTROLLER, false);
     // init controller
     if ($route !== null) {
         $routes[] = $route;
         // cache route
         $route = new Route(null, $route);
         Registry::set([self::KEY_ROUTE_CONTROLLER => $route->getController(), self::KEY_ROUTE_CLASS => $route->getClass(), self::KEY_ROUTE_TEMPLATE => $route->getController()]);
         if ($route->isAction()) {
             Registry::set(self::KEY_ROUTE_ACTION, $route->getAction());
         }
         $this->log->trace('Route set: \'' . Registry::get(self::KEY_ROUTE_CONTROLLER) . '\'', Logger::CATEGORY_DRONE);
     } else {
         $is_index = false;
         $request = $_SERVER['REQUEST_URI'];
         $this->log->trace('Process request: \'' . $request . '\'', Logger::CATEGORY_DRONE);
         Registry::set(self::KEY_REQUEST, $request);
         if (($pos = strpos($request, '?')) !== false) {
             $request = substr($request, 0, $pos);
         }
         unset($pos);
         $routes[] = $request;
         if (substr($request, -1) != '/') {
             // ensure request has web extension
             if (substr($request, -strlen(Registry::get(self::KEY_EXT_WEB))) === Registry::get(self::KEY_EXT_WEB)) {
                 // do not allow direct access to index like '/path/index.htm'
                 if (basename($request) === 'index' . Registry::get(self::KEY_EXT_WEB)) {
                     $this->error(self::ERROR_404);
                     // kick direct index request
                     return;
                 }
                 // rm web extension
                 $request = substr($request, 0, strlen($request) - strlen(Registry::get(self::KEY_EXT_WEB)));
             } else {
                 $this->error(self::ERROR_404);
                 // kick request
                 return;
             }
         } else {
             $is_index = true;
         }
         $r = null;
         foreach ($this->__routes as $r) {
             if ($rf = $r->matchFile($request)) {
                 $this->log->trace('Route file loaded: \'' . $r->getController() . '\'', Logger::CATEGORY_DRONE);
                 foreach ($rf as $k => $v) {
                     $r = new Route($k, $v);
                     if ($r->match($request)) {
                         break 2;
                         // match
                     }
                 }
             } else {
                 if ($r->match($request)) {
                     break;
                     // match
                 }
             }
             $r = null;
             // no match
         }
         if ($r) {
             $this->log->trace('Route (mapped) detected: \'' . $r->getPath() . '\'', Logger::CATEGORY_DRONE);
             Registry::set([self::KEY_ROUTE_CONTROLLER => $r->getController(), self::KEY_ROUTE_CLASS => $r->getClass(), self::KEY_ROUTE_TEMPLATE => $r->getController()]);
             if ($r->isAction()) {
                 Registry::set(self::KEY_ROUTE_ACTION, $r->getAction());
             }
             $this->view->setRouteParams($r->getParams());
//.........这里部分代码省略.........
开发者ID:NHoeller,项目名称:drone,代码行数:101,代码来源:Core.php

示例13: dirname

<?php

// get the absolute path to system
$sys_path = dirname(__FILE__);
// set the include path
set_include_path($sys_path . PATH_SEPARATOR . get_include_path());
// include some required components
require_once 'components/common.php';
require_once 'components/autoload.php';
// get config instance
$config = get_config();
// store the system path in config
$config->set('path.system', $sys_path);
// get route library
$route = new Route();
// get controller, action and request params
$controller = $route->getController();
$action = $route->getAction();
$params = $route->getParams();
// store in config
$config->set('request.controller', $controller);
$config->set('request.action', $action);
$config->set('request.params', $params);
// init the application
$application = new Application($controller, $action);
// EOF
开发者ID:aboxall,项目名称:Framework,代码行数:26,代码来源:bootstrap.php

示例14: runController

 /**
  * Calls an action inside a controller
  * (if at least one of them is not present
  * nothing happens)
  * 
  * @param Route Route
  */
 private function runController(Route $route, array $params)
 {
     $controller = $route->getController();
     $action = $route->getAction();
     Router::$currentController = $controller . '#' . $action;
     ControllerBase::runController($controller, $action, $params);
 }
开发者ID:nicefirework,项目名称:sharecloud,代码行数:14,代码来源:Router.class.php

示例15: testSetController

 public function testSetController()
 {
     $this->object->setController('someController');
     $this->assertEquals('someController', $this->object->getController());
 }
开发者ID:juraj-blahunka,项目名称:Bachelor-Thesis,代码行数:5,代码来源:RouteTest.php


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