You are here

public function UltimenuSkin::getPath in Ultimenu 8.2

A reversed process to convert an option into a full CSS skin path.

This silly reversion ensures the setting will be intact when moving around CSS files, or theme and module directory.

Parameters

string $path: The path that should be converted to full CSS path.

Return value

string The CSS path containing ultimenu skins.

Overrides UltimenuSkinInterface::getPath

1 call to UltimenuSkin::getPath()
UltimenuSkin::libraryInfoBuild in src/UltimenuSkin.php
Implements hook_library_info_build().

File

src/UltimenuSkin.php, line 96

Class

UltimenuSkin
Provides Ultimenu skins utility methods.

Namespace

Drupal\ultimenu

Code

public function getPath($uri) {
  if (!isset($this->skinPath[md5($uri)])) {
    list(, $skin_name) = array_pad(array_map('trim', explode("|", $uri, 2)), 2, NULL);
    if (strpos($uri, "module|") !== FALSE) {
      $skin_path = 'css/theme/' . $skin_name . '.css';
    }
    elseif (strpos($uri, "custom|") !== FALSE) {
      $path = $this
        ->getSetting('skins');
      $skin_path = '/' . $path . '/' . $skin_name . '.css';
    }
    elseif (strpos($uri, "theme|") !== FALSE) {
      $theme_default = $this
        ->getConfig('system.theme')
        ->get('default');
      $path = drupal_get_path('theme', $theme_default) . '/css/ultimenu';
      $skin_path = '/' . $path . '/' . $skin_name . '.css';
    }
    $this->skinPath[md5($uri)] = isset($skin_path) ? $skin_path : '';
  }
  return $this->skinPath[md5($uri)];
}