當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。