Created
April 2, 2012 22:41
-
-
Save JulienBreux/2287709 to your computer and use it in GitHub Desktop.
PrestaShop 1.5.x - Module override in themes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Override of Module Core | |
* Use this override to override (^^) module classes | |
* | |
* @version 1.0.0 | |
* @author Julien BREUX <[email protected]> | |
*/ | |
class Module extends ModuleCore | |
{ | |
/** | |
* Return an instance of the specified module | |
* | |
* @param string $module_name Module name | |
* @return Module | |
*/ | |
public static function getInstanceByName($module_name) | |
{ | |
if (!isset(self::$_INSTANCE[$module_name])) | |
{ | |
if (Tools::file_exists_cache(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php')) | |
{ | |
include_once(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'.php'); | |
$override_module_file = _PS_THEME_DIR_.'modules/'.$module_name.'/'.$module_name.'.php'; | |
if (file_exists($override_module_file)) | |
{ | |
require_once $override_module_file; | |
$module_name .= 'Theme'; | |
} | |
if (class_exists($module_name, false)) | |
return self::$_INSTANCE[$module_name] = new $module_name; | |
} | |
return false; | |
} | |
return self::$_INSTANCE[$module_name]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Complément sur le forum : http://www.prestashop.com/forums/topic/119286-surcharge-fichiers-dun-module/page__pid__837380__st__20#entry837380