You are here

function readmehelp_converter_service in README Help 8

Implements the ReadmeHelpMarkdownConverter service.

If the module name is passed then README* file in the modules root directory will be rendered. If the file path passed is a valid directory within Drupal installation then the first README* file found on the path will be rendered. If the file path is an absolute path to existing Drupal site's file then this file will be rendered disregarding of the file name or extension.

Parameters

string $module_name: (optional) The module to look for the files.

string $file_path: (optional) The alternative file path.

Return value

\Drupal\readmehelp\ReadmeHelpMarkdownConverter|string The markdown converter service or markup generated for a file.

File

./readmehelp.module, line 29
Contains readmehelp.module.

Code

function readmehelp_converter_service($module_name = NULL, $file_path = NULL) {
  $converter = \Drupal::service('readmehelp.markdown_converter');
  if ($module_name) {
    return $converter
      ->convertMarkdownFile($module_name, $file_path);
  }
  return $converter;
}