summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-12 07:42:26 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-12 07:42:26 +0000
commit187f28a6b3f1deecdae913b2958c82d8e16414e1 (patch)
tree5ef490223dc696cb916f39f4c35eba1534cf919a /core/helpers
parent2fb94444d963a288bcb4f0a9bf9a8cffdc9e9e04 (diff)
Yet another deal with bootstrapping when we've got no core install yet.
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/module.php43
1 files changed, 21 insertions, 22 deletions
diff --git a/core/helpers/module.php b/core/helpers/module.php
index ca3eb2cc..dbb96af1 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -24,6 +24,8 @@
* Note: by design, this class does not do any permission checking.
*/
class module_Core {
+ private static $modules = array();
+
public static function get_version($module_name) {
return ORM::factory("module")->where("name", $module_name)->find()->version;
}
@@ -48,19 +50,11 @@ class module_Core {
}
public static function is_installed($module_name) {
- if (!self::_core_installed()) {
- return false;
- }
-
- return ORM::factory("module")->where("name", $module_name)->find()->loaded;
+ return in_array($module_name, self::$modules);
}
public static function installed() {
- if (!self::_core_installed()) {
- return array();
- }
-
- return ORM::factory("module")->find_all();
+ return self::$modules;
}
public static function event($name, &$data=null) {
@@ -85,20 +79,26 @@ class module_Core {
}
public static function load_modules() {
- if (!self::_core_installed()) {
- return array();
- }
+ // This is one of the first database operations that we'll do, so it may fail if there's no
+ // install yet. Try to handle this situation gracefully expecting that the scaffolding will
+ // Do The Right Thing.
+ //
+ // @todo get rid of this extra error checking when we have an installer.
+ set_error_handler(array("module", "_dummy_error_handler"));
try {
- $modules = Kohana::config('core.modules');
-
- foreach (self::installed() as $module) {
- $modules[] = MODPATH . $module->name;
+ $kohana_modules = Kohana::config('core.modules');
+ foreach (ORM::factory("module")->find_all() as $module) {
+ self::$modules[] = $module->as_array();
+ $kohana_modules[] = MODPATH . $module->name;
}
- Kohana::config_set('core.modules', $modules);
+ Kohana::config_set('core.modules', $kohana_modules);
} catch (Exception $e) {
+ self::$modules = array();
}
+
+ restore_error_handler();
}
public function get_var($module_name, $name, $default_value=null) {
@@ -126,11 +126,10 @@ class module_Core {
}
/**
- * Lightweight hack to make sure that we've got a real install.
+ * Dummy error handler used in module::load_modules.
*
- * @todo remove this when we have a real installer.
+ * @todo remove this when we have an installer.
*/
- private static function _core_installed() {
- return Kohana::config('database.default.connection.pass') != 'p@ssw0rd';
+ private static function _dummy_error_handler() {
}
}