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


PHP Hook::getLiveEditById方法代碼示例

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


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

示例1: registerHook

    /**
     * Connect module to a hook
     *
     * @param string $hook_name Hook name
     * @param array $shop_list List of shop linked to the hook (if null, link hook to all shops)
     * @return boolean result
     */
    public function registerHook($hook_name, $shop_list = null)
    {
        // Check hook name validation and if module is installed
        if (!Validate::isHookName($hook_name)) {
            throw new PrestaShopException('Invalid hook name');
        }
        if (!isset($this->id) || !is_numeric($this->id)) {
            return false;
        }
        // Retrocompatibility
        $hook_name_bak = $hook_name;
        if ($alias = Hook::getRetroHookName($hook_name)) {
            $hook_name = $alias;
        }
        Hook::exec('actionModuleRegisterHookBefore', array('object' => $this, 'hook_name' => $hook_name));
        // Get hook id
        $id_hook = Hook::getIdByName($hook_name);
        $live_edit = Hook::getLiveEditById((int) Hook::getIdByName($hook_name_bak));
        // If hook does not exist, we create it
        if (!$id_hook) {
            $new_hook = new Hook();
            $new_hook->name = pSQL($hook_name);
            $new_hook->title = pSQL($hook_name);
            $new_hook->live_edit = pSQL($live_edit);
            $new_hook->add();
            $id_hook = $new_hook->id;
            if (!$id_hook) {
                return false;
            }
        }
        // If shop lists is null, we fill it with all shops
        if (is_null($shop_list)) {
            $shop_list = Shop::getShops(true, null, true);
        }
        $return = true;
        foreach ($shop_list as $shop_id) {
            // Check if already register
            $sql = 'SELECT hm.`id_module`
				FROM `' . _DB_PREFIX_ . 'hook_module` hm, `' . _DB_PREFIX_ . 'hook` h
				WHERE hm.`id_module` = ' . (int) $this->id . ' AND h.`id_hook` = ' . $id_hook . '
				AND h.`id_hook` = hm.`id_hook` AND `id_shop` = ' . (int) $shop_id;
            if (Db::getInstance()->getRow($sql)) {
                continue;
            }
            // Get module position in hook
            $sql = 'SELECT MAX(`position`) AS position
				FROM `' . _DB_PREFIX_ . 'hook_module`
				WHERE `id_hook` = ' . (int) $id_hook . ' AND `id_shop` = ' . (int) $shop_id;
            if (!($position = Db::getInstance()->getValue($sql))) {
                $position = 0;
            }
            // Register module in hook
            $return &= Db::getInstance()->insert('hook_module', array('id_module' => (int) $this->id, 'id_hook' => (int) $id_hook, 'id_shop' => (int) $shop_id, 'position' => (int) ($position + 1)));
        }
        Hook::exec('actionModuleRegisterHookAfter', array('object' => $this, 'hook_name' => $hook_name));
        return $return;
    }
開發者ID:toufikadfab,項目名稱:PrestaShop-1.5,代碼行數:64,代碼來源:Module.php

示例2: registerDesignerHook

 public static function registerDesignerHook($hook_name)
 {
     // Check hook name validation and if module is installed
     if (!Validate::isHookName($hook_name)) {
         throw new PrestaShopException('Invalid hook name');
     }
     // Retrocompatibility
     $hook_name_bak = $hook_name;
     if ($alias = Hook::getRetroHookName($hook_name)) {
         $hook_name = $alias;
     }
     // Get hook id
     $id_hook = Hook::getIdByName($hook_name);
     $live_edit = Hook::getLiveEditById((int) Hook::getIdByName($hook_name_bak));
     // If hook does not exist, we create it
     if (!$id_hook) {
         $new_hook = new Hook();
         $new_hook->name = pSQL($hook_name);
         $new_hook->title = pSQL($hook_name);
         $new_hook->live_edit = pSQL($live_edit);
         $new_hook->add();
         $id_hook = $new_hook->id;
         if (!$id_hook) {
             return false;
         }
     }
     return $id_hook;
 }
開發者ID:tmdhosting,項目名稱:TMDHosting-PrestaShop-Technology-Theme,代碼行數:28,代碼來源:Hook.php


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