public function PluginCommands::clearPluginTypeCaches in Plugin 8.2
Cache clear callback for plugin types.
Parameters
$args string[]: An array of plugin type IDs.
File
- src/
Commands/ PluginCommands.php, line 50
Class
- PluginCommands
- Drush integration for the Plugin module.
Namespace
Drupal\plugin\CommandsCode
public function clearPluginTypeCaches($args = []) {
// Get all plugin types if none given as an additional command parameter.
if (empty($args)) {
$plugin_types = $this->pluginTypeManager
->getPluginTypes();
$args = array_keys($plugin_types);
}
$result = [];
foreach ($args as $plugin_type_id) {
// Complain if a plugin type does not exist.
if (!$this->pluginTypeManager
->hasPluginType($plugin_type_id)) {
throw new \Exception(dt('Plugin type "{type}" does not exist.', [
'type' => $plugin_type_id,
]));
}
$plugin_manager = $this->pluginTypeManager
->getPluginType($plugin_type_id)
->getPluginManager();
if (!$plugin_manager instanceof CachedDiscoveryInterface) {
continue;
}
$plugin_manager
->clearCachedDefinitions();
$result[] = dt('Cleared all "{type}" plugin definitions.', [
'type' => $plugin_type_id,
]);
}
// Show all the output together, to make it a little more compact.
if ($result) {
$this
->io()
->success($result);
}
}