You are here

markdown.install in Markdown 8

Same filename and directory in other branches
  1. 8.2 markdown.install
  2. 3.0.x markdown.install

Install, update and uninstall functions for the markdown module.

File

markdown.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the markdown module.
 */

/**
 * Implements hook_requirements().
 */
function markdown_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $composer_loaded = class_exists('Michelf\\MarkdownExtra') || class_exists('League\\CommonMark\\CommonMarkConverter');
    if (!$composer_loaded && \Drupal::moduleHandler()
      ->moduleExists('libraries')) {
      $library = libraries_detect('php-markdown');
      $error_message = isset($library['error message']) ? $library['error message'] : '';
      if (empty($library['installed'])) {
        $requirements['php_markdown_lib'] = [
          'title' => t('Markdown library'),
          'severity' => REQUIREMENT_ERROR,
          'value' => t('Not found'),
          'description' => t('@error You need to download the <a href=":markdown_link">PHP Markdown Lib</a>, extract the archive and place the directory in the %path directory on your server.', [
            '@error' => $error_message,
            ':markdown_link' => $library['download url'],
            '%path' => 'libraries',
          ]),
        ];
      }
      else {
        $requirements['php_markdown_lib'] = [
          'title' => t('Markdown library'),
          'severity' => REQUIREMENT_OK,
          'value' => $library['name'] . ' ' . $library['version'],
        ];
      }
    }
    elseif (!$composer_loaded) {
      $requirements['php_markdown_lib'] = [
        'title' => t('Markdown library'),
        'severity' => REQUIREMENT_ERROR,
        'value' => t('Not found'),
        'description' => t('You need to use composer to install the <a href=":markdown_link">PHP Markdown Lib</a> and/or the <a href=":commonmark_link">CommonMark Lib</a>.', [
          ':markdown_link' => 'https://packagist.org/packages/michelf/php-markdown',
          ':commonmark_link' => 'https://packagist.org/packages/league/commonmark',
        ]),
      ];
    }
    else {
      $requirements['php_markdown_lib'] = [
        'title' => t('Markdown library'),
        'severity' => REQUIREMENT_OK,
        'value' => t('Library found'),
      ];
    }
  }
  return $requirements;
}

Functions

Namesort descending Description
markdown_requirements Implements hook_requirements().