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


PHP Controller::dispatch方法代码示例

本文整理汇总了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');
     }
 }
开发者ID:joksnet,项目名称:php-old,代码行数:35,代码来源:Router.php

示例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);
 }
开发者ID:minivc,项目名称:minivc,代码行数:30,代码来源:Dispatcher.php

示例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';
 }
开发者ID:joksnet,项目名称:php-old,代码行数:8,代码来源:Configuracion.php

示例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']);
 }
开发者ID:parweb,项目名称:corephp,代码行数:20,代码来源:Router.php

示例5: Controller

<?php

error_reporting(E_ALL);
require 'config.php';
$controller = new Controller();
$controller->dispatch($_GET['perform']);
开发者ID:WellTreatUs,项目名称:php_cassandra_example,代码行数:6,代码来源:index.php

示例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();
开发者ID:JocelynDelalande,项目名称:Lilina,代码行数:28,代码来源:index.php

示例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');
开发者ID:CodeBooks,项目名称:php-master-write-cutting-edge-code,代码行数:11,代码来源:index.php

示例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();
开发者ID:miyamoto-shinji,项目名称:php_01,代码行数:12,代码来源:loader.php

示例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();
 }
开发者ID:AlvarodelRosal,项目名称:xppass,代码行数:19,代码来源:KFL.php

示例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);
     }
 }
开发者ID:chico-rei,项目名称:restify,代码行数:16,代码来源:BaseController.php

示例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();
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:30,代码来源:index.php

示例12:

<?php

include $_SERVER['ROOT_DIR'] . '/autoload.php';
i18n::register();
Session::init();
Controller::dispatch(strtok($_SERVER['REQUEST_URI'], '?'));
开发者ID:teran-mckinney,项目名称:lbry.io,代码行数:6,代码来源:bootstrap.php

示例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();
}
开发者ID:Badacadabra,项目名称:ExifCool,代码行数:31,代码来源:index.php

示例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);
开发者ID:rmfish,项目名称:dnsmasq-api,代码行数:30,代码来源:index.php


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