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


PHP Dispatcher类代码示例

本文整理汇总了PHP中Dispatcher的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher类的具体用法?PHP Dispatcher怎么用?PHP Dispatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: _main_

function _main_()
{
    $ph = new PluginHandler();
    $ph->register(new MyPlugin());
    $sd = new Dispatcher($ph);
    $sd->dispatch();
}
开发者ID:ralphschindler,项目名称:ZF2ByExample,代码行数:7,代码来源:_main_.php

示例2: __autoload

function __autoload($className)
{
    $dispatcher = new Dispatcher($className);
    if (class_exists($className)) {
        return;
    }
    if ($dispatcher->isBom()) {
        require_once Configuration::getModelBomPath() . $className . '.php';
    }
    if ($dispatcher->isDao()) {
        require_once Configuration::getModelDaoPath() . $className . '.php';
    }
    if ($dispatcher->isCoreInterface()) {
        require_once Configuration::getInterfacePath() . $className . ".interface.php";
    }
    if ($dispatcher->isCoreController()) {
        require_once Configuration::getControllersPath() . $className . ".php";
    }
    if ($dispatcher->isCoreBom()) {
        require_once Configuration::getBusinessObjectModelsPath() . $className . ".php";
    }
    if ($dispatcher->isCoreDao()) {
        require_once Configuration::getDatabaseAccessObjectPath() . $className . '.php';
    }
    if ($dispatcher->isCoreConstant()) {
        require_once Configuration::getConstantsPath() . $className . ".constants.php";
    }
    if ($dispatcher->isCoreHelper()) {
        require_once Configuration::getHelpersPath() . $className . ".helper.php";
    }
    if ($dispatcher->isCoreAbstract()) {
        require_once Configuration::getAbstractPath() . $className . '.abstract.php';
    }
}
开发者ID:rawntech-rohan,项目名称:Project-CJ,代码行数:34,代码来源:Bootstrap.php

示例3: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = new Controller();
     $dispatcher = new Dispatcher(new View());
     $dispatcher->setBootstrap(new Bootstrap());
     $this->object->setParams(array('dispatcher' => $dispatcher));
 }
开发者ID:elvis2,项目名称:simple-mvc,代码行数:11,代码来源:ControllerTest.php

示例4: getAjaxTemplate

 private function getAjaxTemplate()
 {
     foreach ($this->vars->isPost() as $key => $value) {
         $data[$key] = $value;
     }
     $dispatcher = new Dispatcher();
     $controller = $dispatcher->setController($data);
     // Assign variables for the template
     if ($controller['vars']) {
         foreach ($controller['vars'] as $key => $value) {
             $this->smarty->assign($key, $value);
         }
     }
     if (isset($data['response'])) {
         if ($data['response'] == 'html') {
             return array('response' => 'html', 'data' => $dispatcher->loadTemplate());
         } elseif ($data['response'] == 'json') {
             return array('response' => 'json', 'data' => json_encode($controller['vars']));
         } else {
             throw new Exception('Ajax dataType must be html or json');
         }
     } else {
         throw new Exception('response data must be given');
     }
 }
开发者ID:kas-test,项目名称:framework,代码行数:25,代码来源:Loader.php

示例5: testServiceDispatchingUriRawUrlWithoutQueryParam

 /**
  * If RequestURI is proper URI and does not contain QueryParam then it will return proper o/p 
  */
 function testServiceDispatchingUriRawUrlWithoutQueryParam()
 {
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_METHOD] = ODataConstants::HTTP_METHOD_GET;
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_PROTOCOL] = ODataConstants::HTTPREQUEST_HEADER_PROTOCOL_HTTP;
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_HOST] = "localhost:8086";
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_URI] = "/NorthWind.svc/Customers";
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_QUERY_STRING] = null;
     try {
         $exceptionThrown = false;
         $dispatcher = new Dispatcher();
         //Service dispatched
         $dispatcher->dispatch();
         $contents = ob_get_contents();
         ob_end_clean();
         $this->assertContains("<feed xml:base=\"http://localhost:8086/NorthWind.svc", $contents);
         $this->assertContains("<id>http://localhost:8086/NorthWind.svc/Customers</id>", $contents);
         $absoluteUri = $dispatcher->getHost()->getAbsoluteRequestUriAsString();
         $this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $absoluteUri);
         $rawUrl = $dispatcher->getHost()->getWebOperationContext()->IncomingRequest()->getRawUrl();
         $this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $rawUrl);
     } catch (\Exception $exception) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         $exceptionThrown = true;
         $this->fail('Without Query Params - An unexpected exception  has been thrown:' . $exception->getMessage());
     }
     if (!$exceptionThrown) {
         $this->assertTrue(TRUE);
     }
     $dispatcher->getHost()->getWebOperationContext()->resetWebContextInternal();
 }
开发者ID:i-geo,项目名称:odataphpprod,代码行数:35,代码来源:DataServiceHostTest.php

示例6: setSail

 /**
  *  T' the high seas! Garrr!
  */
 public function setSail()
 {
     $request = new Request($_GET, $_POST, $_COOKIE, $_SERVER);
     $router = new Router($request);
     $response = new Response();
     $dispatcher = new Dispatcher($router->dispatch(), $response);
     $dispatcher->fireCannons();
 }
开发者ID:delboy1978uk,项目名称:bone,代码行数:11,代码来源:Application.php

示例7: testDispatchNotFoundRoute

 public function testDispatchNotFoundRoute()
 {
     $dispatcher = new Dispatcher($this->router);
     $response = $dispatcher->dispatch('GET', '/not-found');
     assertThat($response, is(anInstanceOf('Rootr\\Response')));
     assertThat($this->readAttribute($response, 'status'), is(equalTo(404)));
     assertThat($this->readAttribute($response, 'body'), is(equalTo('Not Found')));
 }
开发者ID:eddmann,项目名称:rootr,代码行数:8,代码来源:DispatcherTest.php

示例8: _dispatch

 /**
  * Redirects user to action in application with validated response data available as POST data retrievable at
  * $this->request->data` at your app's controller.
  *
  * @param string $url Url in application to dispatch to
  * @param array $data A list with post data
  * @return void
  */
 protected function _dispatch($url, $data)
 {
     $CakeRequest = new CakeRequest($url);
     $CakeRequest->data = $data;
     $Dispatcher = new Dispatcher();
     $Dispatcher->dispatch($CakeRequest, new CakeResponse());
     $this->_stop();
 }
开发者ID:oefenweb,项目名称:cakephp-uni-login,代码行数:16,代码来源:UniLoginController.php

示例9: __construct

 public function __construct(Dispatcher $dispatcher, $fd, $what, $arg = null)
 {
     $this->dispatcher = $dispatcher;
     $this->base = $dispatcher->getBase();
     $this->fd = $fd;
     $this->what = $what;
     $this->argument = $arg;
     $this->callback = [$this->dispatcher, Dispatcher::FORWARD_METHOD_NAME];
 }
开发者ID:panlatent,项目名称:aurora,代码行数:9,代码来源:Listener.php

示例10: dispatch

 /**
  * @desc Redirect the request to the right controller using the url controller mappes list
  * @param UrlControllerMapper[] $url_controller_mappers the url controllers mapper list
  */
 public static function dispatch($url_controller_mappers)
 {
     try {
         $dispatcher = new Dispatcher($url_controller_mappers);
         $dispatcher->dispatch();
     } catch (NoUrlMatchException $ex) {
         self::handle_dispatch_exception($ex);
     }
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:13,代码来源:DispatchManager.class.php

示例11: testRemoveListener

 /**
  */
 public function testRemoveListener()
 {
     $eventName = 'test';
     $dispatcher = new Dispatcher();
     $listener = new Listener($eventName);
     $dispatcher->addListener($eventName, $listener);
     $dispatcher->removeListener($eventName, $listener);
     $this->assertEmpty($dispatcher->getListeners());
 }
开发者ID:Cravid,项目名称:php-event,代码行数:11,代码来源:DispatcherTest.php

示例12: beforeRedirect

 /**
  * Intercept redirect and render amf response
  *
  * @param object $controller
  * @return void
  */
 function beforeRedirect(&$controller, $url, $status = null, $exit = true)
 {
     if ($controller->isAmf && $this->autoRedirect) {
         if (is_array($url)) {
             $url = Router::url($url);
         }
         $Dispatcher = new Dispatcher();
         $Dispatcher->dispatch($url);
         if ($exit) {
             exit;
         }
     }
 }
开发者ID:BGCX067,项目名称:fake-as3-svn-to-git,代码行数:19,代码来源:amf.php

示例13: dispatch

 public static function dispatch(Request $request = null, Response $response = null)
 {
     if ($request === null) {
         $request = new Request();
     }
     if ($response === null) {
         $response = new Response();
     }
     $app = self::instance();
     $app->setRequest($request);
     $dispatcher = new Dispatcher(APP_CONTROLLERS_DIR);
     $dispatcher->dispatch($request, $response);
     $response->send();
 }
开发者ID:nosnebilla,项目名称:default-hub,代码行数:14,代码来源:application.php

示例14: testDispatching

 public function testDispatching()
 {
     $dispatcher = new Dispatcher(['index', 'blog', 'projects', '_drafts/blog']);
     $dispatcher->map('blog', 'bloge');
     $dispatcher->alias('projects', 'projectos');
     $dispatcher->ignore('_drafts/blog');
     $this->assertEquals('blog', $dispatcher->dispatch('bloge'));
     $this->assertEquals('projects', $dispatcher->dispatch('projectos'));
     $this->assertEquals('projects', $dispatcher->dispatch('projects'));
     $this->assertEquals('', $dispatcher->dispatch('_drafts/blog'));
     $this->assertEquals('foobar', $dispatcher->dispatch('foobar'));
 }
开发者ID:bloge,项目名称:bloge,代码行数:12,代码来源:DispatcherTest.php

示例15: _prepareHook

 protected function _prepareHook($params)
 {
     $languages = Language::getLanguages(true, $this->context->shop->id);
     if (!count($languages)) {
         return false;
     }
     $link = new Link();
     if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
         $default_rewrite = array();
         if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
             $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
             $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
             $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
             foreach ($rewrite_infos as $infos) {
                 $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                 $default_rewrite[$infos['id_lang']] = $arr_link;
             }
         }
         $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
     }
     return true;
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:32,代码来源:blocklanguages.php


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