lookupAddon() публичный Метод

Lookup the addon with a given key.
public lookupAddon ( string $key ) : Addon | null
$key string The key of the addon.
Результат Addon | null
Пример #1
0
 /**
  * Define the permissions for an application.
  *
  * @param string $applicationName The name of the application.
  */
 public function registerPermissions($applicationName)
 {
     $addon = $this->addonManager->lookupAddon($applicationName);
     if ($permissions = $addon->getInfoValue('registerPermissions')) {
         Gdn::permissionModel()->define($permissions);
     }
 }
Пример #2
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;
 }
Пример #3
0
 /**
  * Hooks to the various actions, i.e. enable, disable and load.
  *
  * @param string $pluginName The name of the plugin.
  * @param string $forAction Which action to hook it to, i.e. enable, disable or load.
  * @param boolean $callback whether to perform the hook method.
  * @return void
  */
 private function pluginHook($pluginName, $forAction, $callback = false)
 {
     switch ($forAction) {
         case self::ACTION_ENABLE:
             $methodName = 'setup';
             break;
         case self::ACTION_DISABLE:
             $methodName = 'onDisable';
             break;
         default:
             $methodName = '';
     }
     $addon = $this->addonManager->lookupAddon($pluginName);
     if (!$addon || !$addon->getPluginClass()) {
         return;
     }
     $pluginClass = $addon->getPluginClass();
     if ($callback && !empty($pluginClass) && class_exists($pluginClass)) {
         $plugin = new $pluginClass();
         if (method_exists($pluginClass, $methodName)) {
             $plugin->{$methodName}();
         }
     }
 }