本文整理汇总了PHP中Dispatcher::execute方法的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher::execute方法的具体用法?PHP Dispatcher::execute怎么用?PHP Dispatcher::execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dispatcher
的用法示例。
在下文中一共展示了Dispatcher::execute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildRoute
public function buildRoute($uri, $params = null)
{
try {
$params = (array) $params;
$params['uri'] = $uri;
$uri = Dispatcher::execute($this->build, $params);
} catch (\Exception $e) {
//
}
return $uri;
}
示例2: execute
/**
* Realiza el dispatch de una ruta
*
* @return Object
*/
public static function execute($route)
{
extract($route, EXTR_OVERWRITE);
if (!(include_once APP_PATH . "controllers/{$controller_path}" . '_controller.php')) {
throw new KumbiaException(NULL, 'no_controller');
}
//Asigna el controlador activo
$app_controller = Util::camelcase($controller) . 'Controller';
$cont = self::$_controller = new $app_controller($module, $controller, $action, $parameters);
View::select($action);
View::setPath($controller_path);
// Se ejecutan los filtros before
if ($cont->k_callback('initialize') === FALSE) {
return $cont;
}
if ($cont->k_callback('before_filter') === FALSE) {
return $cont;
}
//Se ejecuta el metodo con el nombre de la accion
//en la clase de acuerdo al convenio
if (!method_exists($cont, $action)) {
throw new KumbiaException(NULL, 'no_action');
}
//Obteniendo el metodo
$reflectionMethod = new ReflectionMethod($cont, $action);
//k_callback y __constructor metodo reservado
if ($reflectionMethod->name == 'k_callback' || $reflectionMethod->isConstructor()) {
throw new KumbiaException('Esta intentando ejecutar un método reservado de KumbiaPHP');
}
//se verifica que el metodo sea public
if (!$reflectionMethod->isPublic()) {
throw new KumbiaException(NULL, 'no_action');
}
//se verifica que los parametros que recibe
//la action sea la cantidad correcta
$num_params = count($parameters);
if ($cont->limit_params && ($num_params < $reflectionMethod->getNumberOfRequiredParameters() || $num_params > $reflectionMethod->getNumberOfParameters())) {
throw new KumbiaException("Número de parámetros erroneo para ejecutar la acción \"{$action}\" en el controlador \"{$controller}\"");
}
$reflectionMethod->invokeArgs($cont, $parameters);
//Corre los filtros after
$cont->k_callback('after_filter');
$cont->k_callback('finalize');
//Si esta routed volver a ejecutar
if (Router::getRouted()) {
Router::setRouted(FALSE);
return Dispatcher::execute(Router::get());
// Vuelve a ejecutar el dispatcher
}
return $cont;
}
示例3: main
/**
* Función Principal donde se ejecutan los controladores
*
* @params string $url url
* @return boolean
*/
public static function main($url)
{
/**
* El Router analiza la url
**/
Router::rewrite($url);
/**
* Ciclo del enrutador
*/
$controller = Dispatcher::execute();
while (Router::getRouted()) {
Router::setRouted(false);
$controller = Dispatcher::execute();
}
/**
* Renderiza la vista
**/
if ($controller->view || $controller->template) {
require CORE_PATH . 'kumbia/view.php';
View::render($controller, $url);
} else {
ob_end_flush();
}
// Fin del request
exit;
}
示例4: auto
}
// @see Router
require CORE_PATH . 'kumbia/router.php';
//@see Load
require CORE_PATH . 'kumbia/load.php';
// @see Dispatcher
require CORE_PATH . 'kumbia/dispatcher.php';
// @see Controller
require APP_PATH . 'libs/application_controller.php';
// @see KumbiaView
require APP_PATH . 'libs/view.php';
try {
// Bootstrap de la aplicacion
require APP_PATH . 'libs/bootstrap.php';
// Dispatch y renderiza la vista
View::render(Dispatcher::execute(Router::rewrite($url)), $url);
} catch (KumbiaException $e) {
KumbiaException::handle_exception($e);
}
// Autocarga de clases
function auto($class)
{
// Optimizando carga de ActiveRecord
if ($class == 'ActiveRecord') {
return require APP_PATH . 'libs/active_record.php';
}
// Pasando a smallcase
$class = Util::smallcase($class);
if (is_file(APP_PATH . "extensions/helpers/{$class}.php")) {
return require APP_PATH . "extensions/helpers/{$class}.php";
}
示例5: MRequest
<?php
/**
* M PHP Framework
* @package M
*/
/**
* M PHP Framework
*
* Controller main file for default app
*
* @package M
* @author Arnaud Sellenet <demental at github>
* @license http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version 0.1
*/
define('APP_NAME', '{$APP_NAME}');
require '{$APP_RELATIVE_FILE_TO_ROOT}/M_Startup.php';
require APP_ROOT . 'app/' . APP_NAME . '/routing.php';
$result = Net_URL_Mapper::getInstance()->match($_GET['route']);
$getvalues = array_merge($result, $_GET);
$requestvalues = array_merge($_POST, $get);
$request = new MRequest($getvalues, $requestvalues);
$d = new Dispatcher($request);
$d->setConfig(PEAR::getStaticProperty('Dispatcher', 'global'));
$d->execute();
header('Content-type:text/html; charset=utf-8');
echo $d->display();
示例6: Dispatcher
<?php
/**
* ====== COPYRIGHT ======
* Suicide MVC, A Simple RAD Framework
* Copyright (c) Devin Ireland, http://devinireland.com
*
* Licensed under The Microsoft Public License
* See LICENSE-SMVC.txt in the root folder of this source code.
* Redistributions of files must retain this copyright notice.
* =======================
*
* ----- File Description -----
* This is the root index file that handles requests by
* handing the GET variables off to the dispatcher.
*/
require_once 'Config/global.php';
require_once 'Config/global_script.php';
// Dispatcher initializes the controller and view.
$dispatcher = new Dispatcher(isset($_GET['page']) ? $_GET['page'] : NULL, isset($_GET['action']) ? $_GET['action'] : NULL, isset($_GET['argument']) ? $_GET['argument'] : NULL);
$dispatcher->execute();
示例7: execute
public function execute($callback)
{
return Dispatcher::execute($callback, $this->params);
}
示例8: redirect404
public function redirect404($modulaction, $vars = null, $lang = null, $secure = null)
{
header('Status: 404');
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
$arr = explode('/', $modulaction);
$d = new Dispatcher($arr[0], $arr[1], $this->_params);
$d->execute();
echo $d->display();
exit(0);
}