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


PHP Dispatcher::getInstance方法代码示例

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


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

示例1: testPathWithDefault

 public function testPathWithDefault()
 {
     $_SERVER['SCRIPT_NAME'] = '/default/index.php';
     $this->Dispatcher = Dispatcher::getInstance();
     $this->Dispatcher->setUrl('mycontroller/myaction/p1/1/p2/2/p3/3');
     $this->assertEqual(UrlComponent::path('default/index'), '/default/index');
 }
开发者ID:nicolasmartin,项目名称:framework,代码行数:7,代码来源:component.url.php

示例2: getPhotosLink

 /**
  * Create a link to a photo
  *
  * @param mixed $photo Photos object (can be an ID supplier, but deprecated)
  * @param string $alias
  * @param int $id_lang
  * @return string
  */
 public static function getPhotosLink($photo, $alias = null, $id_lang = null, $id_shop = null)
 {
     if (!$id_lang) {
         $id_lang = Context::getContext()->language->id;
     }
     if ($id_shop === null) {
         $shop = Context::getContext()->shop;
     } else {
         $shop = new Shop($id_shop);
     }
     $url = 'http://' . $shop->domain . $shop->getBaseURI() . $this->getLangLink($id_lang, null, $id_shop);
     $dispatcher = Dispatcher::getInstance();
     if (!is_object($photo)) {
         if ($alias !== null && !$dispatcher->hasKeyword('photo_rule', $id_lang, 'meta_keywords', $id_shop) && !$dispatcher->hasKeyword('photo_rule', $id_lang, 'meta_title', $id_shop)) {
             return $url . $dispatcher->createUrl('photo_rule', $id_lang, array('id' => (int) $photo, 'rewrite' => (string) $alias), $this->allow, '', $id_shop);
         }
         $photo = new Photos($photo, $id_lang);
     }
     // Set available keywords
     $params = array();
     $params['id'] = $photo->id;
     $params['rewrite'] = !$alias ? $photo->link_rewrite : $alias;
     $params['meta_keywords'] = Tools::str2url($photo->meta_keywords);
     $params['meta_title'] = Tools::str2url($photo->meta_title);
     return $url . $dispatcher->createUrl('photo_rule', $id_lang, $params, $this->allow, '', $id_shop);
 }
开发者ID:rongandat,项目名称:vatfairfoot,代码行数:34,代码来源:Link.php

示例3: getPageLink

 /**
  * Create a simple link
  *
  * @param string $controller
  * @param string|array $request
  * @param bool $request_url_encode Use URL encode
  *
  * @return string Page link
  */
 public function getPageLink($controller, $request = null, $request_url_encode = false)
 {
     //If $controller contains '&' char, it means that $controller contains request data and must be parsed first
     $p = strpos($controller, '&');
     if ($p !== false) {
         $request = substr($controller, $p + 1);
         $request_url_encode = false;
         $controller = substr($controller, 0, $p);
     }
     $controller = Tools::strReplaceFirst('.php', '', $controller);
     //need to be unset because getModuleLink need those params when rewrite is enable
     if (is_array($request)) {
         if (isset($request['module'])) {
             unset($request['module']);
         }
         if (isset($request['controller'])) {
             unset($request['controller']);
         }
     } else {
         $request = html_entity_decode($request);
         if ($request_url_encode) {
             $request = urlencode($request);
         }
         parse_str($request, $request);
     }
     $uri_path = Dispatcher::getInstance()->createUrl($controller, $request, false, '');
     return $this->getBaseLink() . ltrim($uri_path, '/');
 }
开发者ID:jessylenne,项目名称:sf2-technical-test,代码行数:37,代码来源:Link.php

示例4: logException

 static function logException(\Exception $e)
 {
     $requestURI = Dispatcher::getInstance()->getCalledURL();
     $requestURILine = sprintf(static::$messageConfigs['default']['line'], 'Request URI', $requestURI);
     $message = static::computeMessage($e, static::$messageConfigs['default'], array($requestURILine));
     \ManiaLib\Utils\Logger::error($message);
 }
开发者ID:kremsy,项目名称:manialib,代码行数:7,代码来源:ErrorHandling.php

示例5: _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

示例6: hookHeader

 public function hookHeader()
 {
     $this->page_name = Dispatcher::getInstance()->getController();
     if ($this->page_name == 'index') {
         $this->_assignMedia();
     }
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:7,代码来源:blockfacebook.php

示例7: hookHeader

 public function hookHeader()
 {
     $this->page_name = Dispatcher::getInstance()->getController();
     if ($this->page_name == 'index') {
         $this->context->controller->addJS($this->_path . 'blockfacebook.js');
     }
 }
开发者ID:dev-lav,项目名称:htdocs,代码行数:7,代码来源:blockfacebook.php

示例8: ModuleHookExec

    private function ModuleHookExec($moduleName, $hook_name)
    {
        $output = '';
        $moduleInstance = Module::getInstanceByName($moduleName);
        if (Validate::isLoadedObject($moduleInstance) && $moduleInstance->id) {
            $altern = 0;
            $id_hook = Hook::getIdByName($hook_name);
            $retro_hook_name = Hook::getRetroHookName($hook_name);
            $disable_non_native_modules = (bool) Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
            if ($disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($moduleInstance->name, self::$native_module)) {
                return '';
            }
            //check disable module
            $device = (int) $this->context->getDevice();
            if (Db::getInstance()->getValue('
			SELECT COUNT(`id_module`) FROM ' . _DB_PREFIX_ . 'module_shop
			WHERE enable_device & ' . (int) $device . ' AND id_module=' . (int) $moduleInstance->id . Shop::addSqlRestriction()) == 0) {
                return '';
            }
            // Check permissions
            $exceptions = $moduleInstance->getExceptions($id_hook);
            $controller = Dispatcher::getInstance()->getController();
            $controller_obj = Context::getContext()->controller;
            //check if current controller is a module controller
            if (isset($controller_obj->module) && Validate::isLoadedObject($controller_obj->module)) {
                $controller = 'module-' . $controller_obj->module->name . '-' . $controller;
            }
            if (in_array($controller, $exceptions)) {
                return '';
            }
            //retro compat of controller names
            $matching_name = array('authentication' => 'auth', 'productscomparison' => 'compare');
            if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions)) {
                return '';
            }
            if (Validate::isLoadedObject($this->context->employee) && !$moduleInstance->getPermission('view', $this->context->employee)) {
                return '';
            }
            if (!isset($hook_args['cookie']) or !$hook_args['cookie']) {
                $hook_args['cookie'] = $this->context->cookie;
            }
            if (!isset($hook_args['cart']) or !$hook_args['cart']) {
                $hook_args['cart'] = $this->context->cart;
            }
            $hook_callable = is_callable(array($moduleInstance, 'hook' . $hook_name));
            $hook_retro_callable = is_callable(array($moduleInstance, 'hook' . $retro_hook_name));
            if (($hook_callable || $hook_retro_callable) && Module::preCall($moduleInstance->name)) {
                $hook_args['altern'] = ++$altern;
                // Call hook method
                if ($hook_callable) {
                    $display = $moduleInstance->{'hook' . $hook_name}($hook_args);
                } elseif ($hook_retro_callable) {
                    $display = $moduleInstance->{'hook' . $retro_hook_name}($hook_args);
                }
                $output .= $display;
            }
        }
        return $output;
    }
开发者ID:zangles,项目名称:lennyba,代码行数:59,代码来源:ovichookmanager.php

示例9: getLiveEditUrl

 /**
  * get live Edit URL
  */
 public function getLiveEditUrl($live_edit_params)
 {
     $url = $this->context->shop->getBaseURL() . Dispatcher::getInstance()->createUrl('index', (int) $this->context->language->id, $live_edit_params);
     if (Configuration::get('PS_REWRITING_SETTINGS')) {
         $url = str_replace('index.php', '', $url);
     }
     return $url;
 }
开发者ID:ekachandrasetiawan,项目名称:BeltcareCom,代码行数:11,代码来源:AdminLeotempcpPanel.php

示例10: hookHeader

 public function hookHeader($params)
 {
     $this->page_name = Dispatcher::getInstance()->getController();
     if ($this->page_name == 'product') {
         $this->context->controller->addCSS($this->_path . 'sendtoafriend.css', 'all');
         $this->context->controller->addJS($this->_path . 'sendtoafriend.js');
     }
 }
开发者ID:Sosiashvili,项目名称:docker-prestashop,代码行数:8,代码来源:sendtoafriend.php

示例11: addOneAndEcho

 public function addOneAndEcho($i)
 {
     $i++;
     echo $i . '-' . $this->name . '<br />';
     $instance = Dispatcher::getInstance();
     $instance::publish($this, $i);
     return $i;
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:8,代码来源:component.php

示例12: publish

 /**
  * Взаимодействуем с каждым подписанным объектом
  *
  * @param $object
  */
 public static function publish($object)
 {
     $instance = Dispatcher::getInstance();
     $id = spl_object_hash($object);
     $subscribers = $instance->listeners[$id];
     foreach ($subscribers as $subscriber) {
         $subscriber->doSomething();
     }
 }
开发者ID:sbogdanov108,项目名称:patterns,代码行数:14,代码来源:dispatcher.php

示例13: __construct

 public function __construct()
 {
     $Dispatcher = Dispatcher::getInstance();
     $Dispatcher->setApp('app');
     $Dispatcher->setControllerName('myController');
     $Dispatcher->setActionName('myAction');
     i18n::setCulture('fr');
     i18n::addDefinitions($this->def);
 }
开发者ID:nicolasmartin,项目名称:framework,代码行数:9,代码来源:core.i18n.php

示例14: publish

 public static function publish($object, $i)
 {
     $instance = Dispatcher::getInstance();
     $id = spl_object_hash($object);
     $subscribers = $instance->listeners[$id];
     foreach ($subscribers as $subscriber) {
         $i = $subscriber->addOneAndEcho($i);
     }
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:9,代码来源:dispatcher.php

示例15: load

 public function load()
 {
     $this->assertIsRunning();
     $this->loadConfig();
     $dispatcher = Dispatcher::getInstance();
     $request = new Request($_SERVER['REQUEST_METHOD']);
     $response = new Response();
     $dispatcher->forward($request, $response);
 }
开发者ID:Juliens,项目名称:pheenix,代码行数:9,代码来源:Server.php


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