diff options
| author | 2014-12-05 14:17:02 +0100 | |
|---|---|---|
| committer | 2014-12-05 14:17:02 +0100 | |
| commit | 9fc60317eecba785b66011f04b9a5150296f2df6 (patch) | |
| tree | 992516f332a1fde1dc0c25da670c3df0fadef07b /lib | |
| parent | a2da70fd119cc43438f8dd88de54a7d19fafbe1a (diff) | |
First draft for listing and manipulate extensions
See https://github.com/FreshRSS/FreshRSS/issues/252
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Minz/Extension.php | 20 | ||||
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 17 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index ecf510ea2..a1fdd659b 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -17,6 +17,8 @@ class Minz_Extension { 'user', ); + private $is_enabled; + /** * The constructor to assign specific information to the extension. * @@ -41,6 +43,8 @@ class Minz_Extension { $this->description = isset($meta_info['description']) ? $meta_info['description'] : ''; $this->version = isset($meta_info['version']) ? $meta_info['version'] : '0.1'; $this->setType(isset($meta_info['type']) ? $meta_info['type'] : 'user'); + + $this->is_enabled = false; } /** @@ -67,6 +71,22 @@ class Minz_Extension { public function init() {} /** + * Set the current extension to enable. + */ + public function enable() { + $this->is_enabled = true; + } + + /** + * Return if the extension is currently enabled. + * + * @return true if extension is enabled, false else. + */ + public function is_enabled() { + return $this->is_enabled; + } + + /** * Getters and setters. */ public function getName() { diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 789557b9e..6c32ccf19 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -144,6 +144,7 @@ class Minz_ExtensionManager { if (isset(self::$ext_list[$ext_name])) { $ext = self::$ext_list[$ext_name]; self::$ext_list_enabled[$ext_name] = $ext; + $ext->enable(); $ext->init(); } } @@ -158,4 +159,20 @@ class Minz_ExtensionManager { self::enable($ext_name); } } + + + + /** + * Returns a list of extensions. + * + * @param $only_enabled if true returns only the enabled extensions (false by default). + * @return an array of extensions. + */ + public static function list_extensions($only_enabled = false) { + if ($only_enabled) { + return self::$ext_list_enabled; + } else { + return self::$ext_list; + } + } } |
