本文整理汇总了PHP中Module::getModuleIdByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::getModuleIdByName方法的具体用法?PHP Module::getModuleIdByName怎么用?PHP Module::getModuleIdByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::getModuleIdByName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDeliveryOptions
public function getDeliveryOptions()
{
$delivery_option_list = $this->context->cart->getDeliveryOptionList();
$include_taxes = !Product::getTaxCalculationMethod((int) $this->context->cart->id_customer) && (int) Configuration::get('PS_TAX');
$display_taxes_label = Configuration::get('PS_TAX') && !Configuration::get('AEUC_LABEL_TAX_INC_EXC');
$carriers_available = array();
if (isset($delivery_option_list[$this->context->cart->id_address_delivery])) {
foreach ($delivery_option_list[$this->context->cart->id_address_delivery] as $id_carriers_list => $carriers_list) {
foreach ($carriers_list as $carriers) {
if (is_array($carriers)) {
foreach ($carriers as $carrier) {
$carrier = array_merge($carrier, $this->objectPresenter->present($carrier['instance']));
$delay = $carrier['delay'][$this->context->language->id];
unset($carrier['instance'], $carrier['delay']);
$carrier['delay'] = $delay;
if ($this->isFreeShipping($this->context->cart, $carriers_list)) {
$carrier['price'] = $this->translator->trans('Free', array(), 'Shop.Theme.Checkout');
} else {
if ($include_taxes) {
$carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_with_tax']);
if ($display_taxes_label) {
$carrier['price'] = sprintf($this->translator->trans('%s tax incl.', array(), 'Shop.Theme.Checkout'), $carrier['price']);
}
} else {
$carrier['price'] = $this->priceFormatter->convertAndFormat($carriers_list['total_price_without_tax']);
if ($display_taxes_label) {
$carrier['price'] = sprintf($this->translator->trans('%s tax excl.', array(), 'Shop.Theme.Checkout'), $carrier['price']);
}
}
}
if (count($carriers) > 1) {
$carrier['label'] = $carrier['price'];
} else {
$carrier['label'] = $carrier['name'] . ' - ' . $carrier['delay'] . ' - ' . $carrier['price'];
}
// If carrier related to a module, check for additionnal data to display
$carrier['extraContent'] = '';
if ($carrier['is_module']) {
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', array('carrier' => $carrier), $moduleId);
}
}
$carriers_available[$id_carriers_list] = $carrier;
}
}
}
}
}
return $carriers_available;
}
示例2: isEnabled
public static function isEnabled($module_name)
{
if (!Cache::isStored('Module::isEnabled' . $module_name)) {
$active = false;
$id_module = Module::getModuleIdByName($module_name);
if (Db::getInstance()->getValue('SELECT `id_module` FROM `' . _DB_PREFIX_ . 'module_shop` WHERE `id_module` = ' . (int) $id_module . ' AND `id_shop` = ' . (int) Context::getContext()->shop->id)) {
$active = true;
}
Cache::store('Module::isEnabled' . $module_name, (bool) $active);
}
return Cache::retrieve('Module::isEnabled' . $module_name);
}
示例3: removeOverride
/**
* Remove all methods in a module override from the override class
*
* @param string $classname
* @return bool
*/
public function removeOverride($classname)
{
$orig_path = $path = PrestaShopAutoload::getInstance()->getClassPath($classname . 'Core');
if ($orig_path && !($file = PrestaShopAutoload::getInstance()->getClassPath($classname))) {
return true;
} else {
if (!$orig_path && Module::getModuleIdByName($classname)) {
$path = 'modules' . DIRECTORY_SEPARATOR . $classname . DIRECTORY_SEPARATOR . $classname . '.php';
}
}
// Check if override file is writable
if ($orig_path) {
$override_path = _PS_ROOT_DIR_ . '/' . $file;
} else {
$override_path = _PS_OVERRIDE_DIR_ . $path;
}
if (!is_file($override_path) || !is_writable($override_path)) {
return false;
}
file_put_contents($override_path, preg_replace('#(\\r|\\r\\n)#ism', "\n", file_get_contents($override_path)));
if ($orig_path) {
// Get a uniq id for the class, because you can override a class (or remove the override) twice in the same session and we need to avoid redeclaration
do {
$uniq = uniqid();
} while (class_exists($classname . 'OverrideOriginal_remove', false));
// Make a reflection of the override class and the module override class
$override_file = file($override_path);
eval(preg_replace(array('#^\\s*<\\?(?:php)?#', '#class\\s+' . $classname . '\\s+extends\\s+([a-z0-9_]+)(\\s+implements\\s+([a-z0-9_]+))?#i'), array(' ', 'class ' . $classname . 'OverrideOriginal_remove' . $uniq), implode('', $override_file)));
$override_class = new ReflectionClass($classname . 'OverrideOriginal_remove' . $uniq);
$module_file = file($this->getLocalPath() . 'override/' . $path);
eval(preg_replace(array('#^\\s*<\\?(?:php)?#', '#class\\s+' . $classname . '(\\s+extends\\s+([a-z0-9_]+)(\\s+implements\\s+([a-z0-9_]+))?)?#i'), array(' ', 'class ' . $classname . 'Override_remove' . $uniq), implode('', $module_file)));
$module_class = new ReflectionClass($classname . 'Override_remove' . $uniq);
// Remove methods from override file
foreach ($module_class->getMethods() as $method) {
if (!$override_class->hasMethod($method->getName())) {
continue;
}
$method = $override_class->getMethod($method->getName());
$length = $method->getEndLine() - $method->getStartLine() + 1;
$module_method = $module_class->getMethod($method->getName());
$module_length = $module_method->getEndLine() - $module_method->getStartLine() + 1;
$override_file_orig = $override_file;
$orig_content = preg_replace('/\\s/', '', implode('', array_splice($override_file, $method->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$module_content = preg_replace('/\\s/', '', implode('', array_splice($module_file, $module_method->getStartLine() - 1, $length, array_pad(array(), $length, '#--remove--#'))));
$replace = true;
if (preg_match('/\\* module: (' . $this->name . ')/ism', $override_file[$method->getStartLine() - 5])) {
$override_file[$method->getStartLine() - 6] = $override_file[$method->getStartLine() - 5] = $override_file[$method->getStartLine() - 4] = $override_file[$method->getStartLine() - 3] = $override_file[$method->getStartLine() - 2] = '#--remove--#';
$replace = false;
}
if (md5($module_content) != md5($orig_content) && $replace) {
$override_file = $override_file_orig;
}
}
// Remove properties from override file
foreach ($module_class->getProperties() as $property) {
if (!$override_class->hasProperty($property->getName())) {
continue;
}
// Replace the declaration line by #--remove--#
foreach ($override_file as $line_number => &$line_content) {
if (preg_match('/(public|private|protected|const)\\s+(static\\s+)?(\\$)?' . $property->getName() . '/i', $line_content)) {
if (preg_match('/\\* module: (' . $this->name . ')/ism', $override_file[$line_number - 4])) {
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
}
$line_content = '#--remove--#';
break;
}
}
}
$count = count($override_file);
for ($i = 0; $i < $count; ++$i) {
if (preg_match('/(\\/\\/.*)/i', $override_file[$i])) {
$override_file[$i] = '#--remove--#';
} elseif (preg_match('/(^\\s*\\/\\*)/i', $override_file[$i])) {
if (!preg_match('/(^\\s*\\* module:)/i', $override_file[$i + 1]) && !preg_match('/(^\\s*\\* date:)/i', $override_file[$i + 2]) && !preg_match('/(^\\s*\\* version:)/i', $override_file[$i + 3]) && !preg_match('/(^\\s*\\*\\/)/i', $override_file[$i + 4])) {
for (; $override_file[$i] && !preg_match('/(.*?\\*\\/)/i', $override_file[$i]); ++$i) {
$override_file[$i] = '#--remove--#';
}
$override_file[$i] = '#--remove--#';
}
}
}
// Rewrite nice code
$code = '';
foreach ($override_file as $line) {
if ($line == '#--remove--#') {
continue;
}
$code .= $line;
}
$to_delete = preg_match('/<\\?(?:php)?\\s+class\\s+' . $classname . '\\s+extends\\s+' . $classname . 'Core\\s*?[{]\\s*?[}]/ism', $code);
}
if (!isset($to_delete) || $to_delete) {
unlink($override_path);
//.........这里部分代码省略.........
示例4: unhookModule
/**
* Unhooks a module hook
*
* @param string $module
* @param string $hook
*
* @return bool
*/
protected function unhookModule($module, $hook)
{
$id_module = Module::getModuleIdByName($module);
$id_hook = Hook::getIdByName($hook);
return Db::getInstance()->delete('hook_module', 'id_module = ' . (int) $id_module . ' AND id_hook = ' . (int) $id_hook);
}
示例5: dirname
*/
include dirname(__FILE__) . '/../../config/config.inc.php';
include dirname(__FILE__) . '/../../init.php';
if (!defined('_PS_VERSION_')) {
exit;
}
// To configure, add webhook in account storename.com/modules/conektaefectivo/notification.php
$body = Tools::file_get_contents('php://input');
$event_json = Tools::jsonDecode($body);
if ($event_json->type == 'charge.paid') {
$charge = $event_json->data->object;
$reference_id = (int) $charge->reference_id;
$id_order = Order::getOrderByCartId($reference_id);
$order = new Order($id_order);
$order_fields = $order->getFields();
$currency_payment = Currency::getPaymentCurrencies(Module::getModuleIdByName('conektaprestashop'), $order_fields['id_shop']);
$total_order_amount = (int) $order->getOrdersTotalPaid();
$str_total_order_amount = (string) $total_order_amount;
$format_total_order_amount = str_pad($str_total_order_amount, strlen($str_total_order_amount) + 2, '0', STR_PAD_RIGHT);
if ($currency_payment[0]['iso_code'] === $charge->currency) {
if ($format_total_order_amount == $charge->amount) {
$orderHistory = new OrderHistory();
$orderHistory->id_order = $order;
$orderHistory->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), $order);
$orderHistory->addWithEmail();
Db::getInstance()->Execute('UPDATE ' . _DB_PREFIX_ . 'conekta_transaction SET status = "paid" WHERE id_order = ' . pSQL($reference_id) . '');
}
}
}
header('HTTP/1.1 200 OK');
exit;
示例6: smartyplugin
/**
*
*/
public static function smartyplugin($params)
{
$id_module = Module::getModuleIdByName($params['module']);
$id_hook = Hook::getIdByName($params['hook']);
$array = array();
$array['id_hook'] = $id_hook;
$array['module'] = $params['module'];
$array['id_module'] = $id_module;
return PtsThemePanelHelper::hookExec($params['hook'], isset($params['args']) ? $params['args'] : array(), $id_module, $array);
}
示例7: getOverrides
/**
* Retrieve an array of the override in the module
*
* @return array|null
*/
public function getOverrides()
{
if (!is_dir($this->getLocalPath() . 'override')) {
return null;
}
$result = array();
foreach (Tools::scandir($this->getLocalPath() . 'override', 'php', '', true) as $file) {
$class = basename($file, '.php');
if (PrestaShopAutoload::getInstance()->getClassPath($class . 'Core') || Module::getModuleIdByName($class)) {
$result[] = $class;
}
}
return $result;
}