function bootstrap_cdn_provider in Express 8
Retrieves a list of available CDN providers for the Bootstrap framework.
// Before.
$providers = bootstrap_cdn_provider();
$jsdelivr = bootstrap_cdn_provider('jsdelivr');
// After.
use Drupal\bootstrap\Bootstrap;
use Drupal\bootstrap\Plugin\ProviderManager;
$theme = Bootstrap::getTheme();
// Get provider definitions, the "equivalent" for bootstrap_cdn_provider().
$provider_manager = new ProviderManager($theme);
$providers = $provider_manager
->getDefinitions();
$jsdelivr = $provider_manager
->getDefinition('jsdelivr');
// You should, however, use the the fully initialized classes made
// available through a theme instance.
$providers = $theme
->getProviders();
$jsdelivr = $theme
->getProvider('jsdelivr');
Parameters
string $provider: A specific provider data to return.
bool $reset: Toggle determining whether or not to reset the database cache.
Return value
array|FALSE An associative array of CDN providers, keyed by their machine name if $provider is not set. If $provider is set and exists, it's individual data array will be returned. If $provider is set and the data does not exist then FALSE will be returned.
Deprecated
Will be removed in a future release.
See also
\Drupal\bootstrap\Plugin\ProviderManager
\Drupal\bootstrap\Theme::getProviders()
\Drupal\bootstrap\Theme::getProvider()
File
- themes/
contrib/ bootstrap/ deprecated.php, line 621 - This contains deprecated functions that will be removed in a future release.
Code
function bootstrap_cdn_provider($provider = NULL, $reset = FALSE) {
Bootstrap::deprecated();
$provider_manager = new ProviderManager(Bootstrap::getTheme());
if ($reset) {
$provider_manager
->clearCachedDefinitions();
}
if (isset($provider)) {
if ($provider_manager
->hasDefinition($provider)) {
return $provider_manager
->getDefinition($provider);
}
return FALSE;
}
return $provider_manager
->getDefinitions();
}