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


PHP Hook::isDisplayHookName方法代碼示例

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


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

示例1: isHookableOn

 /**
  * Check if the module is transplantable on the hook in parameter
  * @param string $hook_name
  * @return bool if module can be transplanted on hook
  */
 public function isHookableOn($hook_name)
 {
     if ($this instanceof WidgetInterface) {
         return Hook::isDisplayHookName($hook_name);
     }
     $retro_hook_name = Hook::getRetroHookName($hook_name);
     return is_callable(array($this, 'hook' . ucfirst($hook_name))) || is_callable(array($this, 'hook' . ucfirst($retro_hook_name)));
 }
開發者ID:M03G,項目名稱:PrestaShop,代碼行數:13,代碼來源:Module.php

示例2: exec


//.........這裏部分代碼省略.........
     $context = Context::getContext();
     if (!isset($hook_args['cookie']) || !$hook_args['cookie']) {
         $hook_args['cookie'] = $context->cookie;
     }
     if (!isset($hook_args['cart']) || !$hook_args['cart']) {
         $hook_args['cart'] = $context->cart;
     }
     $retro_hook_name = Hook::getRetroHookName($hook_name);
     // Look on modules list
     $altern = 0;
     if ($array_return) {
         $output = array();
     } else {
         $output = '';
     }
     if ($disable_non_native_modules && !isset(Hook::$native_module)) {
         Hook::$native_module = Module::getNativeModuleList();
     }
     $different_shop = false;
     if ($id_shop !== null && Validate::isUnsignedId($id_shop) && $id_shop != $context->shop->getContextShopID()) {
         $old_context = $context->shop->getContext();
         $old_shop = clone $context->shop;
         $shop = new Shop((int) $id_shop);
         if (Validate::isLoadedObject($shop)) {
             $context->shop = $shop;
             $context->shop->setContext(Shop::CONTEXT_SHOP, $shop->id);
             $different_shop = true;
         }
     }
     foreach ($module_list as $array) {
         // Check errors
         if ($id_module && $id_module != $array['id_module']) {
             continue;
         }
         if ((bool) $disable_non_native_modules && Hook::$native_module && count(Hook::$native_module) && !in_array($array['module'], Hook::$native_module)) {
             continue;
         }
         // Check permissions
         if ($check_exceptions) {
             $exceptions = Module::getExceptionsStatic($array['id_module'], $array['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)) {
                 continue;
             }
             //Backward compatibility of controller names
             $matching_name = array('authentication' => 'auth');
             if (isset($matching_name[$controller]) && in_array($matching_name[$controller], $exceptions)) {
                 continue;
             }
             if (Validate::isLoadedObject($context->employee) && !Module::getPermissionStatic($array['id_module'], 'view', $context->employee)) {
                 continue;
             }
         }
         if (!($moduleInstance = Module::getInstanceByName($array['module']))) {
             continue;
         }
         if ($use_push && !$moduleInstance->allow_push) {
             continue;
         }
         // Check which / if method is callable
         $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) {
             $hook_args['altern'] = ++$altern;
             if ($use_push && isset($moduleInstance->push_filename) && file_exists($moduleInstance->push_filename)) {
                 Tools::waitUntilFileIsModified($moduleInstance->push_filename, $moduleInstance->push_time_limit);
             }
             // Call hook method
             if ($hook_callable) {
                 $display = Hook::coreCallHook($moduleInstance, 'hook' . $hook_name, $hook_args);
             } elseif ($hook_retro_callable) {
                 $display = Hook::coreCallHook($moduleInstance, 'hook' . $retro_hook_name, $hook_args);
             }
             if ($array_return) {
                 $output[$moduleInstance->name] = $display;
             } else {
                 $output .= $display;
             }
         } elseif (Hook::isDisplayHookName($hook_name)) {
             if ($moduleInstance instanceof WidgetInterface) {
                 $display = Hook::coreRenderWidget($moduleInstance, $hook_name, $hook_args);
                 if ($array_return) {
                     $output[$moduleInstance->name] = $display;
                 } else {
                     $output .= $display;
                 }
             }
         }
     }
     if ($different_shop) {
         $context->shop = $old_shop;
         $context->shop->setContext($old_context, $shop->id);
     }
     return $output;
 }
開發者ID:M03G,項目名稱:PrestaShop,代碼行數:101,代碼來源:Hook.php


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