public function DefinitionDiscoveryFactory::get in Libraries API 8.3
Gets a library definition discovery.
Return value
\Drupal\libraries\ExternalLibrary\Definition\DefinitionDiscoveryInterface The library definition discovery.
File
- src/
ExternalLibrary/ Definition/ DefinitionDiscoveryFactory.php, line 72
Class
- DefinitionDiscoveryFactory
- Instantiates a library definition discovery based on configuration.
Namespace
Drupal\libraries\ExternalLibrary\DefinitionCode
public function get() {
$config = $this->configFactory
->get('libraries.settings');
if ($config
->get('definition.remote.enable')) {
$discovery = new ChainDefinitionDiscovery();
$local_discovery = new WritableFileDefinitionDiscovery($this->localSerializer, $config
->get('definition.local.path'));
$discovery
->addDiscovery($local_discovery);
foreach ($config
->get('definition.remote.urls') as $remote_url) {
$remote_discovery = new GuzzleDefinitionDiscovery($this->httpClient, $this->remoteSerializer, $remote_url);
$discovery
->addDiscovery($remote_discovery);
}
}
else {
$discovery = new FileDefinitionDiscovery($this->localSerializer, $config
->get('definition.local.path'));
}
return $discovery;
}