本文整理汇总了PHP中Controller::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::dispatch方法的具体用法?PHP Controller::dispatch怎么用?PHP Controller::dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::dispatch方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
public static function dispatch()
{
$url = new Url();
$uri = $url->getPath();
foreach (array_reverse(self::$routes, true) as $route => $class) {
if (preg_match("~^{$route}\$~", $uri, $params)) {
Router::$current = $class;
$return = call_user_func_array(array('Controller', 'dispatch'), array_merge(array($class), array_slice($params, 1)));
if (!(false === $return)) {
$vars = get_class_vars($class);
$type = 'text/html';
if (isset($vars['type'])) {
$type = $vars['type'];
}
# PHP >= 5.3
# if ( isset($class::$type) )
# $type = $class::$type;
//Response::setHeader('Content-Type', 'application/xhtml+xml');
Response::setHeader('Content-Type', "{$type};charset=UTF-8");
Response::setBody($class, $return);
return;
}
Router::$current = null;
}
}
if (Response::getHttpResponseCode() == 200) {
$class = 'Error404';
$return = Controller::dispatch($class);
Response::setHeader('Content-Type', 'text/html;charset=UTF-8');
Response::setBody($class, $return);
//Response::setHeader('HTTP/1.0 404 Not Found');
//Response::setHttpResponseCode(404);
//Response::setBody('404', 'Error 404');
}
}
示例2: dispatch
public function dispatch()
{
// Searches routes array matching the url path
foreach ($this->routes as $key => $value) {
// convert route params into valid regex
$regex = preg_replace('<@(\\w+)>', '(?<$1>[\\w-]+)', $key);
$match = preg_match("<^{$regex}\$>", $this->path, $matches);
if ($match) {
break;
}
}
// If match, evaluate the route, otherwise use default route
if ($match) {
$route = preg_replace_callback('|@([\\w\\d-]+)|', function ($keys) use(&$matches) {
return @$matches[$keys[1]];
}, $value);
} else {
$route = 'error/404';
}
// Split parts (file, class, action)
$parts = explode('->', $route);
$controller_file = $parts[0];
$controller_action = (count($parts) > 1 ? $parts[1] : 'index') . 'Action';
$controller_class = basename($parts[0]);
// Parameters
$params = array_merge($matches, $_GET);
// Dispatch controller
require "{$controller_file}.php";
Controller::dispatch($controller_class, $controller_action, $params);
}
示例3: post
public function post()
{
$return = @file_put_contents('application.ini', Controller::dispatch('Helpers_Config', $this->config));
if (false === $return) {
return '/admin/configuracion?error=1';
}
return '/admin/configuracion?edited=1';
}
示例4: dispatch
/**
* Dispatch request
*/
public static function dispatch()
{
$uri = preg_replace('/^\\/( ?=. )|( ?<=. )\\/$/', '', $_SERVER['PATH_INFO'] ?: '/');
$options = null;
foreach (self::$routes as $route) {
if ($options = $route->match($uri)) {
break;
}
}
if (!$options) {
throw new Router\Exception('No route matches');
}
foreach ($options as $param => $value) {
$_REQUEST[$param] = $value;
}
\Controller::dispatch($options['controller'], $options['action']);
}
示例5: Controller
<?php
error_reporting(E_ALL);
require 'config.php';
$controller = new Controller();
$controller->dispatch($_GET['perform']);
示例6: define
<?php
// $Id$
/**
* Initialization page
* @author Ryan McCue <cubegames@gmail.com>
* @package Lilina
* @version 1.0
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/** */
define('LILINA_PATH', dirname(__FILE__));
define('LILINA_INCPATH', LILINA_PATH . '/inc');
$settings = array();
require_once LILINA_INCPATH . '/core/install-functions.php';
lilina_check_installed();
require_once LILINA_INCPATH . '/core/conf.php';
lilina_level_playing_field();
require_once LILINA_INCPATH . '/core/plugin-functions.php';
$timer_start = lilina_timer_start();
require_once LILINA_INCPATH . '/core/version.php';
Locale::load_default_textdomain();
require_once LILINA_INCPATH . '/core/feed-functions.php';
require_once LILINA_INCPATH . '/core/file-functions.php';
require_once LILINA_INCPATH . '/core/skin.php';
do_action('init');
//Templates::load();
Controller::dispatch();
示例7: RouterRegex
<?php
require_once 'Controller.php';
require_once 'RouterRegex.php';
$router = new RouterRegex();
$router->addRoute("/:controller/:action/alnum:user/int:photoId/in/regex:(?P<groupType>([a-z]+?))-(?P<groupId>([0-9]+?))");
$router->addRoute("/error", array('controller' => 'error', 'action' => 'showError'));
$controller = new Controller();
$controller->setRouter($router);
$controller->dispatch('/photos/getPhoto/dshafik/5584010786/in/set-72157626290864145');
$controller->dispatch('/users/dshafik');
示例8: dirname
<?php
/*
* Copyright(c) 2009 limitlink,Inc. All Rights Reserved.
* http://limitlink.jp/
* 文字コード UTF-8
*/
require dirname(__FILE__) . '/controller.php';
$controller = new Controller();
$hash = $controller->dispatch();
$view = new ApplicationView($hash);
$helper = new Helper();
示例9: run
/**
* run
* @access public
* @return void
*/
public function run()
{
// set up core components;
$this->setup();
View::assignLanguage();
// use controller to dispatch
Controller::dispatch($this->mDefaultController, $this->mCore);
// use view
View::display();
if ($this->mCache) {
$this->mCache->save();
}
$this->execTime();
}
示例10: dispatch
/**
* Executes command and returns the response created by the response factory.
*
* @param mixed $command
* @return mixed|HttpResponse
*/
protected function dispatch($command)
{
try {
$data = parent::dispatch($command);
return $this->responseFactory->create($data);
} catch (Exception $e) {
Log::debug($e->getMessage() . ': ' . $e->getTraceAsString());
return $this->responseFactory->create($e);
}
}
示例11: dirname
<?php
// $Id: index.php 424 2009-06-26 10:54:53Z cubegames $
/**
* Initialization page
* @author Ryan McCue <cubegames@gmail.com>
* @package Lilina
* @version 1.0
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
/** */
define('LILINA_PATH', dirname(__FILE__));
define('LILINA_INCPATH', LILINA_PATH . '/inc');
$settings = array();
error_reporting(E_ALL);
require_once LILINA_INCPATH . '/core/install-functions.php';
lilina_check_installed();
require_once LILINA_INCPATH . '/core/conf.php';
lilina_level_playing_field();
require_once LILINA_INCPATH . '/core/plugin-functions.php';
$timer_start = lilina_timer_start();
require_once LILINA_INCPATH . '/core/version.php';
Locale::load_default_textdomain();
require_once LILINA_INCPATH . '/core/feed-functions.php';
require_once LILINA_INCPATH . '/core/file-functions.php';
require_once LILINA_INCPATH . '/core/skin.php';
do_action('init');
//Templates::load();
$controller = new Controller();
$controller->dispatch();
示例12:
<?php
include $_SERVER['ROOT_DIR'] . '/autoload.php';
i18n::register();
Session::init();
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
示例13: Controller
case "about":
$title = "À propos | ExifCool";
$meta_title = "À propos de l'application | ExifCool";
$meta_description = "Détails techniques sur la mise en place de l'application.";
$meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photographer.jpg";
$meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool" . $_SERVER['REQUEST_URI'];
break;
case "detail":
$title = $_GET['t'];
$meta_title = $_GET['t'];
$meta_description = "Une photo disponible sur ExifCool";
$meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photos/" . $_GET['q'];
$meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool" . $_SERVER['REQUEST_URI'];
break;
}
} else {
$ctrl = new Controller();
$res = $ctrl->dispatch();
$title = "Accueil | ExifCool";
$meta_title = "Galerie d'images | ExifCool";
$meta_description = "Une galerie d'images pour le module UMDN3C";
$meta_image = $_SERVER['SERVER_NAME'] . "/ExifCool/ui/images/photographer.jpg";
$meta_url = $_SERVER['SERVER_NAME'] . "/ExifCool";
}
require_once "includes/header.html";
echo $res;
require_once "includes/footer.html";
} catch (Exception $e) {
header('Content-Type: text/html; charset=utf-8');
echo $e->getMessage();
}
示例14: setReturnCode
}
function setReturnCode($code, $text)
{
header("HTTP/1.0 " . $code . " " . $text);
}
}
$output = new Output();
$method = $_SERVER["REQUEST_METHOD"];
if ($method == "GET") {
if (strlen($security_token_read) > 0) {
if (!isset($_SERVER["HTTP_X_AUTH_TOKEN"]) || $_SERVER["HTTP_X_AUTH_TOKEN"] != $security_token_read) {
$output->setReturnCode(401, "Not authorized");
die("Not authorized\n");
}
}
} else {
if (strlen($security_token_write) > 0) {
if (!isset($_SERVER["HTTP_X_AUTH_TOKEN"]) || $_SERVER["HTTP_X_AUTH_TOKEN"] != $security_token_write) {
$output->setReturnCode(401, "Not authorized");
die("Not authorized\n");
}
}
}
$controller = new Controller($host_d_path, $reload_command, $lease_file);
$controller->setOutput($output);
$request = $_SERVER["REQUEST_URI"];
if (strlen($_SERVER["QUERY_STRING"]) > 0) {
$request = substr($request, 0, strlen($_SERVER["REQUEST_URI"]) - strlen($_SERVER["QUERY_STRING"]) - 1);
}
$controller->dispatch($method, $request, file_get_contents('php://input'), $_GET);