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


PHP HookManager::_hook_modules_cache_exec方法代码示例

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


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

示例1: getHookModuleExecList

 /**
  * Get list of modules we can execute per hook
  *
  * @param string $hook_name Get list of modules for this hook if given
  * @return array
  */
 public static function getHookModuleExecList($hook_name = null)
 {
     $context = Context::getContext();
     $cache_id = 'ovic_hook_module_exec_list_' . (isset($context->shop->id) ? '_' . $context->shop->id : '') . (isset($context->customer) ? '_' . $context->customer->id : '');
     if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayBackOfficeHeader') {
         $frontend = true;
         $groups = array();
         $use_groups = Group::isFeatureActive();
         if (isset($context->employee)) {
             $frontend = false;
         } else {
             // Get groups list
             if ($use_groups) {
                 if (isset($context->customer) && $context->customer->isLogged()) {
                     $groups = $context->customer->getGroups();
                 } elseif (isset($context->customer) && $context->customer->isLogged(true)) {
                     $groups = array((int) Configuration::get('PS_GUEST_GROUP'));
                 } else {
                     $groups = array((int) Configuration::get('PS_UNIDENTIFIED_GROUP'));
                 }
             }
         }
         // SQL Request
         $sql = new DbQuery();
         $sql->select('h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`');
         $sql->from('module', 'm');
         if ($hook_name != 'displayBackOfficeHeader') {
             $sql->join(Shop::addSqlAssociation('module', 'm', true, 'module_shop.enable_device & ' . (int) Context::getContext()->getDevice()));
             $sql->innerJoin('module_shop', 'ms', 'ms.`id_module` = m.`id_module`');
         }
         $sql->innerJoin('ovic_backup_hook_module', 'hm', 'hm.`id_module` = m.`id_module`');
         $sql->innerJoin('hook', 'h', 'hm.`id_hook` = h.`id_hook`');
         if ($hook_name != 'displayPayment') {
             $sql->where('h.name != "displayPayment"');
         } elseif ($frontend) {
             if (Validate::isLoadedObject($context->country)) {
                 $sql->where('(h.name = "displayPayment" AND (SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country mc WHERE mc.id_module = m.id_module AND id_country = ' . (int) $context->country->id . ' AND id_shop = ' . (int) $context->shop->id . ' LIMIT 1) = ' . (int) $context->country->id . ')');
             }
             if (Validate::isLoadedObject($context->currency)) {
                 $sql->where('(h.name = "displayPayment" AND (SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency mcr WHERE mcr.id_module = m.id_module AND id_currency IN (' . (int) $context->currency->id . ', -1, -2) LIMIT 1) IN (' . (int) $context->currency->id . ', -1, -2))');
             }
         }
         if (Validate::isLoadedObject($context->shop)) {
             $sql->where('hm.id_shop = ' . (int) $context->shop->id);
         }
         if ($frontend) {
             if ($use_groups) {
                 $sql->leftJoin('module_group', 'mg', 'mg.`id_module` = m.`id_module`');
                 if (Validate::isLoadedObject($context->shop)) {
                     $sql->where('mg.id_shop = ' . (int) $context->shop->id . ' AND  mg.`id_group` IN (' . implode(', ', $groups) . ')');
                 } else {
                     $sql->where('mg.`id_group` IN (' . implode(', ', $groups) . ')');
                 }
             }
         }
         $sql->groupBy('hm.id_hook, hm.id_module');
         $sql->orderBy('hm.`position`');
         $list = array();
         if ($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) {
             foreach ($result as $row) {
                 $row['hook'] = strtolower($row['hook']);
                 if (!isset($list[$row['hook']])) {
                     $list[$row['hook']] = array();
                 }
                 $list[$row['hook']][] = array('id_hook' => $row['id_hook'], 'module' => $row['module'], 'id_module' => $row['id_module'], 'live_edit' => $row['live_edit']);
             }
         }
         if ($hook_name != 'displayPayment' && $hook_name != 'displayBackOfficeHeader') {
             Cache::store($cache_id, $list);
             // @todo remove this in 1.6, we keep it in 1.5 for retrocompatibility
             self::$_hook_modules_cache_exec = $list;
         }
     } else {
         $list = Cache::retrieve($cache_id);
     }
     // If hook_name is given, just get list of modules for this hook
     if ($hook_name) {
         $retro_hook_name = strtolower(Hook::getRetroHookName($hook_name));
         $hook_name = strtolower($hook_name);
         $return = array();
         $inserted_modules = array();
         if (isset($list[$hook_name])) {
             $return = $list[$hook_name];
         }
         foreach ($return as $module) {
             $inserted_modules[] = $module['id_module'];
         }
         if (isset($list[$retro_hook_name])) {
             foreach ($list[$retro_hook_name] as $retro_module_call) {
                 if (!in_array($retro_module_call['id_module'], $inserted_modules)) {
                     $return[] = $retro_module_call;
                 }
             }
         }
//.........这里部分代码省略.........
开发者ID:zangles,项目名称:lennyba,代码行数:101,代码来源:Hookmanager.php


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