protected function InstallablePluginManager::convertInstalledToLibraries in Markdown 8.2
Converts plugin definitions using the old "installed" method to libraries.
Parameters
\Drupal\markdown\Annotation\InstallablePlugin $plugin: The definition being processed.
Deprecated
in markdown:8.x-2.0 and is removed from markdown:3.0.0. There is no replacement.
See also
https://www.drupal.org/project/markdown/issues/3142418
1 call to InstallablePluginManager::convertInstalledToLibraries()
- InstallablePluginManager::processDefinition in src/
PluginManager/ InstallablePluginManager.php - Performs extra processing on plugin definitions.
File
- src/
PluginManager/ InstallablePluginManager.php, line 148
Class
- InstallablePluginManager
- Installable Plugin Manager.
Namespace
Drupal\markdown\PluginManagerCode
protected function convertInstalledToLibraries(InstallablePlugin $plugin) {
// Immediately return if "installed" isn't set.
if (empty($installed = $plugin->installed)) {
return;
}
$installs = [];
foreach ((array) $plugin->installed as $key => $value) {
$object = NULL;
if ($value !== TRUE) {
$object = static::normalizeClassName(is_string($key) && strpos($key, '\\') !== FALSE ? $key : $value);
$installs[$object] = is_array($value) ? $value : [];
}
}
foreach ($installs as $class => $definition) {
$library = InstallableLibrary::create()
->merge($definition);
$library->object = $class;
$plugin->libraries[] = $library;
}
unset($plugin->installed);
// Retrieve the first library and merge any standalone properties on
// the plugin.
$library = reset($plugin->libraries);
// Move URL property over to library.
if (($url = $plugin->url) && !$library->url) {
$library->url = $url;
unset($plugin->url);
}
// Move version property over to library.
if (($version = $plugin->version) && !$library->version) {
$library->version = $version;
unset($plugin->version);
}
// Move/convert versionConstraint into a requirement on library.
if ($versionConstraint = $plugin->versionConstraint) {
$requirement = new InstallableRequirement();
$requirement->constraints['Version'] = [
'name' => $plugin
->id(),
'constraint' => $versionConstraint,
];
$library->requirements[] = $requirement;
unset($plugin->versionConstraint);
}
}