示例#1
0
 /**
  * Builds plugins list that will be passed to templates engine.
  *
  * @return array
  */
 protected function buildPluginsList()
 {
     $plugins = array();
     foreach (PluginUtils::discoverPlugins() as $plugin_name) {
         $plugin = new PluginInfo($plugin_name);
         $plugins[] = array('name' => $plugin_name, 'version' => $plugin->isInstalled() ? $plugin->getInstalledVersion() : $plugin->getVersion(), 'dependencies' => array_merge($plugin->getSystemRequirements(), $plugin->getDependencies()), 'enabled' => $plugin->isEnabled(), 'installed' => $plugin->isInstalled(), 'needsUpdate' => $plugin->needsUpdate(), 'canBeEnabled' => $plugin->canBeEnabled(), 'canBeDisabled' => $plugin->canBeDisabled(), 'canBeUninstalled' => $plugin->canBeUninstalled(), 'canBeUpdated' => $plugin->canBeUpdated(), 'state' => $this->getPluginState($plugin));
     }
     return $plugins;
 }
示例#2
0
 /**
  * Tries to uninstall a plugin.
  *
  * @param string $plugin_name Name of the plugin to uninstall.
  * @return boolean Indicates if the plugin has been uninstalled or not.
  */
 public function uninstall($plugin_name)
 {
     $plugin = new PluginInfo($plugin_name);
     if (!$plugin->isInstalled()) {
         // The plugin was not installed
         return true;
     }
     if (!$plugin->canBeUninstalled()) {
         // The plugin cannot be uninstalled.
         return false;
     }
     // Try to uninstall the plugin.
     $plugin_class = $plugin->getClass();
     if (!$plugin_class::uninstall()) {
         // Something went wrong. The plugin cannot be uninstalled.
         return false;
     }
     // The plugin state is not needed anymore.
     $plugin->clearState();
     return true;
 }