getAllPlugins()); $filter = $this->hasPluginsFilter ?? 'enabled'; // Apply the hasPluginsFilter on the list of plugins to return if ($filter !== 'all') { foreach ($plugins as $i => $identifier) { $disabled = $manager->isDisabled($identifier); if ( (!$disabled && $filter === 'disabled') || ($disabled && $filter === 'enabled') ) { unset($plugins[$i]); } } } return $plugins; } /** * Get the desired plugin name from the input. * @throws InvalidArgumentException if the provided plugin name is invalid */ public function getPluginIdentifier($identifier = null): string { $pluginManager = PluginManager::instance(); $pluginName = $identifier ?? $this->argument('plugin'); $pluginName = $pluginManager->normalizeIdentifier($pluginName); if ( (isset($this->validatePluginInput) && $this->validatePluginInput !== false) && !$pluginManager->hasPlugin($pluginName) ) { throw new InvalidArgumentException(sprintf('Plugin "%s" could not be found.', $pluginName)); } return $pluginName; } /** * Get the plugin instance for the input. * @throws InvalidArgumentException if the provided plugin name is invalid */ public function getPlugin($identifier = null): ?PluginBase { return PluginManager::instance()->findByIdentifier($this->getPluginIdentifier($identifier)); } }