getEnabled() public method

Get the enabled addons, sorted by priority with the highest priority first.
public getEnabled ( ) : array[Addon]
return array[Addon]
 /**
  * Get an list of enabled application folders.
  *
  * @return array Returns an array of all of the enabled application folders.
  * @deprecated
  */
 public function enabledApplicationFolders()
 {
     deprecated('Gdn_ApplicationManager->enabledApplicationFolders()');
     $addons = $this->addonManager->getEnabled();
     $applications = array_filter($addons, Addon::makeFilterCallback(['oldType' => 'application']));
     $result = ['dashboard'];
     /* @var Addon $application */
     foreach ($applications as $application) {
         $result[] = $application->getKey();
     }
     return array_unique($result);
 }
 /**
  * Register all enabled plugins' event handlers and overrides.
  *
  * Examines all declared classes, identifying which ones implement
  * Gdn_IPlugin and registers all of their event handlers and method
  * overrides. It recognizes them because Handlers end with _Handler,
  * _Before, and _After and overrides end with "_Override". They are prefixed
  * with the name of the class and method (or event) to be handled or
  * overridden.
  *
  * For example:
  *
  *  class MyPlugin implements Gdn_IPlugin {
  *   public function MyController_SignIn_After($Sender) {
  *      // Do something neato
  *   }
  *   public function Url_AppRoot_Override($WithDomain) {
  *      return "MyCustomAppRoot!";
  *   }
  *  }
  */
 public function registerPlugins()
 {
     $enabled = $this->addonManager->getEnabled();
     foreach ($enabled as $addon) {
         /* @var \Vanilla\Addon $addon */
         if ($pluginClass = $addon->getPluginClass()) {
             // Include the plugin here, rather than wait for it to hit the autoloader. This way is much faster.
             include_once $addon->getClassPath($pluginClass);
             // Only register the plugin if it implements the Gdn_IPlugin interface.
             if (is_a($pluginClass, 'Gdn_IPlugin', true) && !isset($this->registeredPlugins[$pluginClass])) {
                 // Register this plugin's methods
                 $this->registerPlugin($pluginClass);
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Returns the name of the enabled application based on $ApplicationFolder.
  *
  * @param string The application folder related to the application name you want to return.
  */
 public function enabledApplication($folder = '')
 {
     if ($folder == '') {
         $folder = $this->applicationFolder;
     }
     if (strpos($folder, 'plugins/') === 0) {
         $plugin = StringBeginsWith($folder, 'plugins/', false, true);
         if (array_key_exists($plugin, $this->addonManager->getEnabled())) {
             return $plugin;
         }
         return false;
     } else {
         $addon = $this->addonManager->lookupAddon($folder);
         if ($addon) {
             return $addon->getRawKey();
         }
     }
     return false;
 }