Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Force modules/gallery to be at the end of the module load path, so

that all other modules can override the core code.
  • Loading branch information...
commit 7fd6fcaf9b4d814455758963acf1236034494362 1 parent d8f2c9f
@bharat bharat authored
Showing with 11 additions and 17 deletions.
  1. +1 −1  application/config/config.php
  2. +10 −16 modules/gallery/helpers/module.php
View
2  application/config/config.php
@@ -119,7 +119,7 @@
*/
$config['modules'] = array(
MODPATH . 'forge',
- MODPATH . 'gallery',
+ MODPATH . 'gallery', // gallery must be *last* in the order
);
if (TEST_MODE) {
View
26 modules/gallery/helpers/module.php
@@ -107,7 +107,7 @@ static function active() {
*/
static function install($module_name) {
$kohana_modules = Kohana::config("core.modules");
- $kohana_modules[] = MODPATH . $module_name;
+ array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
@@ -116,7 +116,7 @@ static function install($module_name) {
}
// Now the module is installed but inactive, so don't leave it in the active path
- array_pop($kohana_modules);
+ array_shift($kohana_modules);
Kohana::config_set("core.modules", $kohana_modules);
log::success(
@@ -131,7 +131,7 @@ static function install($module_name) {
*/
static function activate($module_name) {
$kohana_modules = Kohana::config("core.modules");
- $kohana_modules[] = MODPATH . $module_name;
+ array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
@@ -145,15 +145,15 @@ static function activate($module_name) {
$module->save();
}
- self::load_modules();
graphics::activate_rules($module_name);
log::success(
"module", t("Activated module %module_name", array("module_name" => $module_name)));
}
/**
- * Deactivate an installed module. This will call <module>_installer::deactivate() which
- * should take any cleanup steps to make sure that the module isn't visible in any way.
+ * Deactivate an installed module. This will call <module>_installer::deactivate() which should
+ * take any cleanup steps to make sure that the module isn't visible in any way. Note that the
+ * module remains available in Kohana's cascading file system until the end of the request!
* @param string $module_name
*/
static function deactivate($module_name) {
@@ -168,7 +168,6 @@ static function deactivate($module_name) {
$module->save();
}
- self::load_modules();
graphics::deactivate_rules($module_name);
log::success(
"module", t("Deactivated module %module_name", array("module_name" => $module_name)));
@@ -194,7 +193,6 @@ static function uninstall($module_name) {
// We could delete the module vars here too, but it's nice to leave them around
// in case the module gets reinstalled.
- self::load_modules();
log::success(
"module", t("Uninstalled module %module_name", array("module_name" => $module_name)));
}
@@ -203,23 +201,19 @@ static function uninstall($module_name) {
* Load the active modules. This is called at bootstrap time.
*/
static function load_modules() {
- // Reload module list from the config file since we'll do a refresh after calling install()
- $core = Kohana::config_load("core");
- $kohana_modules = $core["modules"];
- $modules = ORM::factory("module")->find_all();
-
self::$modules = array();
self::$active = array();
- foreach ($modules as $module) {
+ $kohana_modules = array();
+ foreach (ORM::factory("module")->where("name <>", "gallery")->find_all() as $module) {
self::$modules[$module->name] = $module;
if ($module->active) {
self::$active[] = $module;
}
$kohana_modules[] = MODPATH . $module->name;
- // @todo: force 'gallery' to be at the end
}
- Kohana::config_set("core.modules", $kohana_modules);
+ Kohana::config_set(
+ "core.modules", array_merge($kohana_modules, Kohana::config("core.modules")));
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.