/** * Gather installed plugins * * @return array of Plugin child classes instances */ public static function getInstalledPlugins() { if (is_null(self::$plugins)) { self::$plugins = array(); $file = self::getPath(self::INSTALLED_PLUGINS_FILE); if (!file_exists($file)) { return array(); } $metadata = json_decode(file_get_contents($file)); foreach ($metadata as $name => $data) { $path = self::getPath($name . '/'); if (!is_dir($path)) { throw new PluginNotFoundException($name); } $class = $name . 'Plugin'; if (!class_exists($class)) { continue; } self::$plugins[$name] = array('class' => $class, 'path' => $path, 'enabled' => call_user_func($class . '::getConfig', 'enabled'), 'meta' => (array) $data); } } return self::$plugins; }