當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Hook::getIdByName方法代碼示例

本文整理匯總了PHP中Hook::getIdByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Hook::getIdByName方法的具體用法?PHP Hook::getIdByName怎麽用?PHP Hook::getIdByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Hook的用法示例。


在下文中一共展示了Hook::getIdByName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getModuleAssign

 public function getModuleAssign($module_name = '', $name_hook = '')
 {
     //$module_id = 7 ; $id_hook = 21 ;
     if (!$module_name || !$name_hook) {
         return;
     }
     $module = Module::getInstanceByName($module_name);
     $module_id = $module->id;
     $id_hook = Hook::getIdByName($name_hook);
     $hook_name = $name_hook;
     if (!$module) {
         return;
     }
     $module_name = $module->name;
     if (Validate::isLoadedObject($module) && $module->id) {
         $array = array();
         $array['id_hook'] = $id_hook;
         $array['module'] = $module_name;
         $array['id_module'] = $module->id;
         if (_PS_VERSION_ < "1.5") {
             return self::lofHookExec($hook_name, array(), $module->id, $array);
         } else {
             $hook_name = substr($hook_name, 7, strlen($hook_name));
             return self::renderModuleByHookV15($hook_name, array(), $module->id, $array);
         }
     }
     return '';
 }
開發者ID:IngenioContenidoDigital,項目名稱:serta,代碼行數:28,代碼來源:Staticblock.php

示例2: renderForm

    public function renderForm($data)
    {
        $helper = $this->getFormHelper();
        $id_shop = Context::getContext()->shop->id;
        if (isset($data['params']['hookmodule'])) {
            $hid = Hook::getIdByName($data['params']['hookmodule']);
            if ($hid) {
                $hms = Hook::getModulesFromHook($hid);
                foreach ($hms as $hm) {
                    if ($data['params']['loadmodule'] == $hm['name']) {
                        $id_module = $hm['id_module'];
                        $module = Module::getInstanceById($id_module);
                        if (Validate::isLoadedObject($module)) {
                            !$module->unregisterHook((int) $hid, array($id_shop));
                        }
                    }
                }
            }
        }
        $modules = Module::getModulesInstalled(0);
        $output = array();
        $hooks = array('displayHome', 'displayLeftColumn', 'displayRightColumn', 'displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayMainmenu', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayMapLocal', 'displayFooterBottom');
        foreach ($hooks as $hook) {
            $output[] = array('name' => $hook, 'id' => $hook);
        }
        $this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'select', 'label' => $this->l('Select A Module'), 'name' => 'loadmodule', 'options' => array('query' => $modules, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A Module is used as widget. the hook of this module was unhooked.')), array('type' => 'select', 'label' => $this->l('Select A Hook'), 'name' => 'hookmodule', 'options' => array('query' => $output, 'id' => 'name', 'name' => 'name'), 'default' => '1', 'desc' => $this->l('Select A hook is used to render module\'s content. the hook of this module was unhooked. 
						You could not rollback it\'s position. So you need asign it in position management of prestashop.'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
        $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $a = $this->getConfigFieldsValues($data);
        $helper->tpl_vars = array('fields_value' => $a, 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang);
        return $helper->generateForm($this->fields_form);
    }
開發者ID:vuduykhuong1412,項目名稱:GitHub,代碼行數:32,代碼來源:module.php

示例3: 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

示例4: upgrade_module_2_5_8

function upgrade_module_2_5_8($module)
{
    $hook_to_remove_id = Hook::getIdByName('advancedPaymentApi');
    if ($hook_to_remove_id) {
        $module->unregisterHook((int) $hook_to_remove_id);
    }
    return true;
}
開發者ID:prestashop,項目名稱:ps_checkpayment,代碼行數:8,代碼來源:upgrade-2.5.8.php

示例5: install

 public function install()
 {
     self::$obj_ts_common->install();
     $return = parent::install() && $this->registerHook('displayBackOfficeHeader') && $this->registerHook('orderConfirmation') && $this->registerHook('newOrder') && $this->registerHook('actionOrderStatusPostUpdate') && $this->registerHook('Footer') && $this->registerHook('paymentTop') && $this->registerHook('orderConfirmation');
     $id_hook = _PS_VERSION_ < '1.5' ? Hook::get('payment') : Hook::getIdByName('payment');
     $this->updatePosition($id_hook, 0, 1);
     return $return;
 }
開發者ID:alexsimple,項目名稱:trustedshops,代碼行數:8,代碼來源:trustedshops.php

示例6: upgrade_module_1_1

function upgrade_module_1_1($module)
{
    $hook_to_remove_id = Hook::getIdByName('displayAfterBodyOpeningTag');
    if ($hook_to_remove_id) {
        $module->unregisterHook((int) $hook_to_remove_id);
    }
    return Configuration::deleteByName('NW_CONFIRMATION_OPTIN');
}
開發者ID:prestashop,項目名稱:ps_emailsubscription,代碼行數:8,代碼來源:install-1-1.php

示例7: upgrade_module_3_0_0

function upgrade_module_3_0_0($module)
{
    $result = true;
    $hook_to_remove_ids = [Hook::getIdByName('displayPaymentEU'), Hook::getIdByName('payment')];
    foreach ($hook_to_remove_ids as $hook_to_remove_id) {
        $result &= $module->unregisterHook((int) $hook_to_remove_id);
    }
    $result &= $module->registerHook('paymentOptions');
    return $result;
}
開發者ID:prestashop,項目名稱:ps_checkpayment,代碼行數:10,代碼來源:upgrade-3.0.0.php

示例8: install

 public function install()
 {
     $homeHookID = $this->isPrestaShop15x ? $this->isPrestaShop16x ? Hook::getIdByName('displayTopColumn') : Hook::getIdByName('displayHome') : Hook::get('home');
     $headerHookID = $this->isPrestaShop15x ? Hook::getIdByName('displayHeader') : Hook::get('header');
     if (!parent::install() or !$this->registerHook($this->isPrestaShop15x ? 'displayHeader' : 'header') or !$this->registerHook($this->isPrestaShop15x ? 'displayFooterProduct' : 'productFooter') or !$this->registerHook($this->isPrestaShop15x ? 'displayFooter' : 'footer') or !$this->installDB() or !$this->fixCSS() or !$this->registerHook($this->isPrestaShop15x ? $this->isPrestaShop16x ? 'displayTopColumn' : 'displayHome' : 'home') or !$this->updatePosition($homeHookID, 0, 1) or !$this->createImageFolder('magicscroll') or !$this->updatePosition($headerHookID, 0, 1)) {
         return false;
     }
     $this->sendStat('install');
     return true;
 }
開發者ID:Eximagen,項目名稱:3m,代碼行數:10,代碼來源:magicscroll.php

示例9: upgrade_module_1_5_1

function upgrade_module_1_5_1($module)
{
    if (Hook::getIdByName('displayPaymentEu')) {
        return true;
    }
    $new_hook = new Hook();
    $new_hook->name = 'displayPaymentEu';
    $new_hook->title = 'Display EU payment options (helper)';
    $new_hook->description = 'Hook to display payment options';
    $new_hook->position = true;
    $new_hook->live_edit = false;
    return (bool) $new_hook->add() && (bool) $module->registerModulesBackwardCompatHook();
}
開發者ID:prestashop,項目名稱:advancedeucompliance,代碼行數:13,代碼來源:upgrade-1.5.1.php

示例10: checkOwnerHooks

 private function checkOwnerHooks()
 {
     $hookspos = array('displayTop', 'displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayRightColumn', 'displayLeftColumn', 'displayHome', 'displayFooter', 'displayBottom', 'displayContentBottom', 'displayFootNav', 'displayFooterTop', 'displayFooterBottom');
     foreach ($hookspos as $hook) {
         if (Hook::getIdByName($hook)) {
         } else {
             $new_hook = new Hook();
             $new_hook->name = pSQL($hook);
             $new_hook->title = pSQL($hook);
             $new_hook->add();
         }
     }
     return true;
 }
開發者ID:downten,項目名稱:ecomblockmanufacturer,代碼行數:14,代碼來源:ecomblockmanufacturer.php

示例11: _postProcess

 private function _postProcess()
 {
     if (Tools::isSubmit('submitBlockCategories')) {
         $pref = $_POST['pref'];
         $old_values = self::getPreferences();
         $new_values = array_merge(self::$default_values, $pref);
         Configuration::updateValue('PSBLOG_CATEGORIES_CONF', base64_encode(serialize($new_values)));
         if ($new_values['block_categories_position'] != $old_values['block_categories_position']) {
             $old_hook_id = Hook::getIdByName($old_values['block_categories_position']);
             $this->unregisterHook($old_hook_id);
             $this->registerHook($new_values['block_categories_position']);
         }
         $this->_html .= '<div class="conf confirm">' . $this->l('Settings updated') . '</div>';
     }
 }
開發者ID:rongandat,項目名稱:vatfairfoot,代碼行數:15,代碼來源:psblogcategories.php

示例12: execHookStockManagerFactory

 /**
  *  Looks for a StockManager in the modules list.
  *
  *  @return StockManagerInterface
  */
 public static function execHookStockManagerFactory()
 {
     $modules_infos = Hook::getModulesFromHook(Hook::getIdByName('stockManager'));
     $stock_manager = false;
     foreach ($modules_infos as $module_infos) {
         $module_instance = Module::getInstanceByName($module_infos['name']);
         if (is_callable(array($module_instance, 'hookStockManager'))) {
             $stock_manager = $module_instance->hookStockManager();
         }
         if ($stock_manager) {
             break;
         }
     }
     return $stock_manager;
 }
開發者ID:IngenioContenidoDigital,項目名稱:americana,代碼行數:20,代碼來源:StockManagerFactory.php

示例13: execHookTaxManagerFactory

 /**
  * Check for a tax manager able to handle this type of address in the module list
  *
  * @param Address $address
  * @param string $type
  *
  * @return TaxManager
  */
 public static function execHookTaxManagerFactory(Address $address, $type)
 {
     $modules_infos = Hook::getModulesFromHook(Hook::getIdByName('taxManager'));
     $tax_manager = false;
     foreach ($modules_infos as $module_infos) {
         $module_instance = Module::getInstanceByName($module_infos['name']);
         if (is_callable(array($module_instance, 'hookTaxManager'))) {
             $tax_manager = $module_instance->hookTaxManager(array('address' => $address, 'params' => $type));
         }
         if ($tax_manager) {
             break;
         }
     }
     return $tax_manager;
 }
開發者ID:IngenioContenidoDigital,項目名稱:americana,代碼行數:23,代碼來源:TaxManagerFactory.php

示例14: moveRightColumn

 public function moveRightColumn($position)
 {
     if (_PS_VERSION_ < '1.5') {
         $hookRight = (int) Hook::get('rightColumn');
     } else {
         $hookRight = (int) Hook::getIdByName('rightColumn');
     }
     $moduleInstance = Module::getInstanceByName($this->name);
     if (_PS_VERSION_ < '1.5') {
         $moduleInfo = Hook::getModuleFromHook($hookRight, $moduleInstance->id);
     } else {
         $moduleInfo = Hook::getModulesFromHook($hookRight, $moduleInstance->id);
     }
     if (isset($moduleInfo['position']) && (int) $moduleInfo['position'] > (int) $position || isset($moduleInfo['m.position']) && (int) $moduleInfo['m.position'] > (int) $position) {
         return $moduleInstance->updatePosition($hookRight, 0, (int) $position);
     }
     return $moduleInstance->updatePosition($hookRight, 1, (int) $position);
 }
開發者ID:Evil1991,項目名稱:PrestaShop-1.4,代碼行數:18,代碼來源:paypal_tools.php

示例15: remove_hook_by_hookname

 public function remove_hook_by_hookname($handle)
 {
     $fonts = $this->get_all_hooks();
     if (!empty($fonts)) {
         foreach ($fonts as $key => $font) {
             if ($font['hookname'] == $handle) {
                 unset($fonts[$key]);
                 //start unregister hook
                 $mod_obj = Module::getInstanceByName('revsliderprestashop');
                 $id_hook = Hook::getIdByName($handle);
                 $mod_obj->unregisterHook($id_hook);
                 //End unregister hook
                 $do = sdsconfig::setval('sds_rev_hooks', $fonts);
                 return true;
             }
         }
     }
     return __('Hook not found! Wrong Hook given.', REVSLIDER_TEXTDOMAIN);
 }
開發者ID:evgrishin,項目名稱:se1614,代碼行數:19,代碼來源:hooks.class.php


注:本文中的Hook::getIdByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。