try { $plugin =
$pluginManager->
getPluginByName($pluginName);
} catch (Exception
$e) { $output->
writeln(sprintf('Plugin by name "%s" was not found.',
$pluginName));
return 1;
} $installationContext = null;
if ($plugin->
getInstalled()) { $output->
writeln(sprintf('The plugin %s is already installed.',
$pluginName));
} else { $installationContext =
$pluginManager->
installPlugin($plugin);
$output->
writeln(sprintf('Plugin %s has been installed successfully.',
$pluginName));
} $activationContext = null;
if ($input->
getOption('activate'
)) { $activationContext =
$pluginManager->
activatePlugin($plugin);
$output->
writeln(sprintf('Plugin %s has been activated successfully.',
$pluginName));
}