class ChainLocator in Libraries API 8.3
Provides a locator utilizing a chain of other individual locators.
Plugin annotation
@Locator("chain");
Hierarchy
- class \Drupal\libraries\Plugin\libraries\Locator\ChainLocator implements LocatorInterface
Expanded class hierarchy of ChainLocator
See also
\Drupal\libraries\ExternalLibrary\Local\LocatorInterface
File
- src/
Plugin/ libraries/ Locator/ ChainLocator.php, line 15
Namespace
Drupal\libraries\Plugin\libraries\LocatorView source
class ChainLocator implements LocatorInterface {
/**
* The locators to check.
*
* @var \Drupal\libraries\ExternalLibrary\Local\LocatorInterface[]
*/
protected $locators = [];
/**
* Add a locator to the chain.
*
* @param \Drupal\libraries\ExternalLibrary\Local\LocatorInterface $locator
* A locator to add to the chain.
*/
public function addLocator(LocatorInterface $locator) {
$this->locators[] = $locator;
return $this;
}
/**
* Locates a library.
*
* @param \Drupal\libraries\ExternalLibrary\Local\LocalLibraryInterface $library
* The library to locate.
*
* @see \Drupal\libraries\ExternalLibrary\Local\LocatorInterface::locate()
*/
public function locate(LocalLibraryInterface $library) {
foreach ($this->locators as $locator) {
$locator
->locate($library);
if ($library
->isInstalled()) {
return;
}
}
$library
->setUninstalled();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ChainLocator:: |
protected | property | The locators to check. | |
ChainLocator:: |
public | function | Add a locator to the chain. | |
ChainLocator:: |
public | function |
Locates a library. Overrides LocatorInterface:: |