public function getExceptions($id_hook) { if (self::$exceptionsCache == NULL and !is_array(self::$exceptionsCache)) { self::$exceptionsCache = array(); $result = Db::getInstance()->ExecuteS(' SELECT CONCAT(id_hook, \'-\', id_module) as `key`, `file_name` as value FROM `' . _DB_PREFIX_ . 'hook_module_exceptions`'); foreach ($result as $row) { if (empty($row['value'])) { continue; } if (!array_key_exists($row['key'], self::$exceptionsCache)) { self::$exceptionsCache[$row['key']] = array(); } self::$exceptionsCache[$row['key']][] = array('file_name' => $row['value']); } } return array_key_exists((int) $id_hook . '-' . (int) $this->id, self::$exceptionsCache) ? self::$exceptionsCache[(int) $id_hook . '-' . (int) $this->id] : array(); }
public function getExceptions($hookID, $dispatch = false) { if (self::$exceptionsCache === null) { self::$exceptionsCache = array(); $sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'hook_module_exceptions` WHERE `id_shop` IN (' . implode(', ', Shop::getContextListShopID()) . ')'; $result = Db::getInstance()->executeS($sql); foreach ($result as $row) { if (!$row['file_name']) { continue; } $key = $row['id_hook'] . '-' . $row['id_module']; if (!isset(self::$exceptionsCache[$key])) { self::$exceptionsCache[$key] = array(); } if (!isset(self::$exceptionsCache[$key][$row['id_shop']])) { self::$exceptionsCache[$key][$row['id_shop']] = array(); } self::$exceptionsCache[$key][$row['id_shop']][] = $row['file_name']; } } $key = $hookID . '-' . $this->id; if (!$dispatch) { $files = array(); foreach (Shop::getContextListShopID() as $shop_id) { if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id])) { foreach (self::$exceptionsCache[$key][$shop_id] as $file) { if (!in_array($file, $files)) { $files[] = $file; } } } } return $files; } else { $list = array(); foreach (Shop::getContextListShopID() as $shop_id) { if (isset(self::$exceptionsCache[$key], self::$exceptionsCache[$key][$shop_id])) { $list[$shop_id] = self::$exceptionsCache[$key][$shop_id]; } } return $list; } }