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


PHP Dispatcher::run方法代码示例

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


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

示例1: processResponseBodies

 /**
  * Builds a composite AMF response based on the response bodies inside the 
  * original AMF request.
  *
  * @return Zend_Amf_Response_Http
  */
 public function processResponseBodies()
 {
     $responseBodies = $this->request->getAmfBodies();
     foreach ($responseBodies as $body) {
         //Extract params from request body
         $return = $this->extractUriAndParams($body);
         //Create fake request object
         $liRequest = new Request(array('data' => $return['params']));
         //Assign URL to request based on details
         if (isset($return['source'])) {
             $liRequest->url = '/' . $return['source'] . '/' . $return['method'];
         } elseif (isset($return['targetURI'])) {
             $liRequest->url = '/' . $return['targetURI'];
         }
         //Assign request params
         $liRequest->params += $return['params'];
         //Dispatch the request normally, and get the controller data
         $controllerResponse = Dispatcher::run($liRequest);
         //Add on the response data (or error) to the current response
         if (isset($controllerResponse->body['error'])) {
             $netStatusEvent = new StdClass();
             $netStatusEvent->_explicitType = 'flex.messaging.messages.ErrorMessage';
             $netStatusEvent->faultString = $controllerResponse->body['error'];
             $newBody = new \Zend_Amf_Value_MessageBody($body->getResponseURI() . \Zend_AMF_Constants::STATUS_METHOD, null, $netStatusEvent);
             $this->response->addAmfBody($newBody);
         } else {
             $newBody = new \Zend_Amf_Value_MessageBody($body->getResponseURI() . \Zend_AMF_Constants::STATUS_METHOD, null, $controllerResponse->body);
             $this->response->addAmfBody($newBody);
         }
     }
     return $this->response;
 }
开发者ID:raisinbread,项目名称:li3_amf,代码行数:38,代码来源:Amf.php

示例2: testPluginControllerLookupFail

 public function testPluginControllerLookupFail()
 {
     Dispatcher::config(array('classes' => array('router' => __CLASS__)));
     $this->expectException("/Controller `some_invalid_plugin.Controller` not found/");
     Dispatcher::run(new Request(array('url' => '/plugin')));
 }
开发者ID:nashadalam,项目名称:lithium,代码行数:6,代码来源:DispatcherTest.php

示例3: array

<?php

require 'bootstrap.php';
use lithium\net\http\Router;
use lithium\action\Dispatcher;
use lithium\action\Response;
Router::connect('/', array(), function ($request) {
    $body = '<h1>Welcome to Sinatrium</h1>';
    return new Response(compact('body'));
});
Router::connect('/hello/{:name}', array('name' => false), function ($request) {
    $name = ucwords($request->name) ?: 'World';
    $body = "<h1>Hello {$name}!</h1>";
    return new Response(compact('body'));
});
echo Dispatcher::run(new lithium\action\Request());
开发者ID:raisinbread,项目名称:sinatrium,代码行数:16,代码来源:index.php

示例4: dirname

 * directory as your application.  If you use the same libraries in multiple applications, you can
 * set this to a shared path on your server.
 */
define('LITHIUM_LIBRARY_PATH', dirname(__DIR__) . '/libraries');
/**
 * Locate and load Lithium core library files.  Throws a fatal error if the core can't be found.
 * If your Lithium core directory is named something other than 'lithium', change the string below.
 */
if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
    $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
    $message .= __FILE__ . ".  It should point to the directory containing your ";
    $message .= "/libraries directory.";
    throw new ErrorException($message);
}
/**
 * Add Lithium
 */
Libraries::add('lithium');
/**
 * Include routes
 */
include 'routes.php';
/**
 * Include filters
 */
include 'filters.php';
/**
 * Run It!
 */
echo Dispatcher::run(new Request());
开发者ID:jamalsa,项目名称:minium,代码行数:30,代码来源:index.php


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