public function GridStack::getIconUri in GridStack 8.2
Same name and namespace in other branches
- 8 src/Entity/GridStack.php \Drupal\gridstack\Entity\GridStack::getIconUri()
Returns the icon URI.
1 call to GridStack::getIconUri()
- GridStack::getIconUrl in src/
Entity/ GridStack.php - Returns the icon URL.
File
- src/
Entity/ GridStack.php, line 354
Class
- GridStack
- Defines the GridStack configuration entity.
Namespace
Drupal\gridstack\EntityCode
public function getIconUri() {
$id = $this
->id();
// The icon was updated, and stored at public://gridstack/ directory.
if ($uri = $this
->getIconFileUri()) {
return $uri;
}
// The icon may be empty, or not, yet not always exists at public directory.
$uri = $this
->getOption('icon');
$dependencies = $this
->getDependencies();
$module = isset($dependencies['module'][0]) && !empty($dependencies['module'][0]) ? $dependencies['module'][0] : '';
// Support static icons at MODULE_NAME/images/OPTIONSET_ID.png as long as
// the module dependencies are declared explicitly for the stored optionset.
if (empty($uri) || !is_file($uri)) {
// Reset to empty first.
$uri = '';
if ($module && \gridstack()
->getModuleHandler()
->moduleExists($module)) {
$icon_path = \drupal_get_path('module', $module) . '/images/' . $id . '.png';
if (is_file(\Drupal::root() . '/' . $icon_path)) {
$uri = \base_path() . $icon_path;
}
}
}
return $uri;
}