Exemplo n.º 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;
 }
Exemplo n.º 2
0
 /**
  * Tries to disable a plugin.
  *
  * @param string $plugin_name Name of the plugin to disable.
  * @return boolean Indicates if the plugin has been disabled or not.
  */
 public function disable($plugin_name)
 {
     $plugin = new PluginInfo($plugin_name);
     if (!$plugin->isEnabled()) {
         // The plugin is not enabled
         return true;
     }
     if (!$plugin->canBeDisabled()) {
         // The plugin cannot be disabled
         return false;
     }
     $plugin->getState()->enabled = false;
     $plugin->getState()->save();
     return true;
 }