-
Notifications
You must be signed in to change notification settings - Fork 3
/
markdown.install
61 lines (56 loc) · 2.12 KB
/
markdown.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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;
}