3 namespace Drupal\libraries\Plugin\libraries\Locator;
5 use Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface;
6 use Drupal\libraries\ExternalLibrary\Local\LocatorInterface;
9 * Provides a locator utilizing a chain of other individual locators.
13 * @see \Drupal\libraries\ExternalLibrary\Local\LocatorInterface
15 class ChainLocator implements LocatorInterface {
18 * The locators to check.
20 * @var \Drupal\libraries\ExternalLibrary\Local\LocatorInterface[]
22 protected $locators = [];
25 * Add a locator to the chain.
27 * @param \Drupal\libraries\ExternalLibrary\Local\LocatorInterface $locator
28 * A locator to add to the chain.
30 public function addLocator(LocatorInterface $locator) {
31 $this->locators[] = $locator;
38 * @param \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $library
39 * The library to locate.
41 * @see \Drupal\libraries\ExternalLibrary\Local\LocatorInterface::locate()
43 public function locate(LocalLibraryInterface $library) {
44 foreach ($this->locators as $locator) {
45 $locator->locate($library);
46 if ($library->isInstalled()) {
50 $library->setUninstalled();