You are here

protected function LibraryDeriver::getHostExtension in UI Patterns 8

Get extension name that hosts the given YAML definition file.

Parameters

string $pathname: YAML definition file full path.

Return value

bool|string Either extension machine name or FALSE if not found.

1 call to LibraryDeriver::getHostExtension()
LibraryDeriver::getPatterns in modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php
Get pattern definition objects.

File

modules/ui_patterns_library/src/Plugin/Deriver/LibraryDeriver.php, line 188

Class

LibraryDeriver
Class LibraryDeriver.

Namespace

Drupal\ui_patterns_library\Plugin\Deriver

Code

protected function getHostExtension($pathname) {
  $extensions = $this
    ->getExtensionLocations();
  $parts = explode(DIRECTORY_SEPARATOR, $pathname);
  while (!empty($parts)) {
    $path = implode(DIRECTORY_SEPARATOR, $parts);
    if (isset($extensions[$path])) {
      return $extensions[$path];
    }
    array_pop($parts);
  }
  return FALSE;
}