You are here

public function AdvancedHelpManager::getTopicFileInfo in Advanced Help 8

Load and render a help topic.

@todo allow the theme override the help.

Parameters

$module:

$topic:

Return value

array

1 call to AdvancedHelpManager::getTopicFileInfo()
AdvancedHelpManager::getTopicFileName in src/AdvancedHelpManager.php

File

src/AdvancedHelpManager.php, line 227

Class

AdvancedHelpManager
AdvancedHelp plugin manager.

Namespace

Drupal\advanced_help

Code

public function getTopicFileInfo($module, $topic) {
  $language = \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId();
  $info = $this
    ->getTopic($module, $topic);
  if (empty($info)) {
    return FALSE;
  }
  $path_type = preg_match('/themes/', $info['path']) ? 'theme' : 'module';

  // Search paths:
  $paths = [
    // // Allow theme override.
    //      path_to_theme() . '/help',
    // Translations.
    drupal_get_path($path_type, $module) . "/translations/help/{$language}",
    // In same directory as .inc file.
    $info['path'],
  ];
  foreach ($paths as $path) {
    if (file_exists("{$path}/{$info['file']}")) {
      return [
        'path' => $path,
        'file' => $info['file'],
      ];
    }
  }
  return FALSE;
}