id = $plugin_id; $this->locatorFactory = $locator_factory; $this->detectorFactory = $detector_factory; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $plugin_id, $container->get('plugin.manager.libraries.locator'), $container->get('plugin.manager.libraries.version_detector') ); } /** * {@inheritdoc} */ public function onLibraryCreate(LibraryInterface $library) { if ($library instanceof LocalLibraryInterface) { $library->getLocator($this->locatorFactory)->locate($library); // Fallback on global locators. // @todo Consider if global locators should be checked as a fallback or as // the primary locator source. if (!$library->isInstalled()) { $this->locatorFactory->createInstance('global')->locate($library); } // Also fetch version information. if ($library instanceof VersionedLibraryInterface) { // @todo Consider if this should be wrapped in some conditional logic // or exception handling so that version detection errors do not // prevent a library from being loaded. $library->getVersionDetector($this->detectorFactory)->detectVersion($library); } } } }