function icon_providers in Icon API 8
Same name and namespace in other branches
- 7 icon.module \icon_providers()
Returns information about all icon providers.
Parameters
string $name: The name of the provider to load.
bool $reset: Boolean to force reset of the cached data. Default: FALSE.
Return value
array|false An associative array containing information for all providers.
See also
hook_icon_info()
4 calls to icon_providers()
- icon_clear_all_caches in includes/
cache.inc - Clears all caches used by the icon module.
- icon_providers_support_import in ./
icon.module - Returns information about whether a provider supports importing.
- icon_provider_import_form_validate in includes/
import.inc - Validate callback for 'icon_provider_import_form'.
- icon_provider_load in ./
icon.module - Load a specific provider.
1 string reference to 'icon_providers'
- icon_hook_info in ./
icon.module - Implements hook_hook_info().
File
- ./
icon.module, line 627 - icon.module Provides icon integration with menu items.
Code
function icon_providers($name = NULL, $reset = FALSE) {
$providers =& drupal_static(__FUNCTION__);
if (!isset($providers) || $reset) {
if (!$reset && ($cache = \Drupal::cache()
->get('icon_providers')) && !empty($cache->data)) {
$providers = $cache->data;
}
else {
$providers = array();
// Invoke hook_icon_providers().
foreach (icon_extension_implements('icon_providers') as $extension => $type) {
$extension_providers = (array) icon_extension_invoke($type, $extension, 'icon_providers');
foreach ($extension_providers as $provider_name => $provider) {
if ($provider_name === 'automatic') {
drupal_set_message(t('The !type %extension tried to specify a provider with the name: %name. This is a reserved name and cannot be used, please rename your provider.', array(
'!type' => $type,
'%extension' => $extension,
'%name' => $provider_name,
)), 'warning');
continue;
}
icon_provider_defaults($provider, $provider_name);
$provider['name'] = $provider_name;
$provider['type'] = $type;
$provider[$type] = $extension;
$providers[$provider_name] = $provider;
}
}
// Allow extensions to alter the providers.
\Drupal::moduleHandler()
->alter('icon_providers', $providers);
// Cache the info.
\Drupal::cache()
->set('icon_providers', $providers);
}
}
if (!empty($name)) {
if (!empty($providers[$name])) {
return $providers[$name];
}
return FALSE;
}
return $providers;
}