-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathace_editor.install
More file actions
57 lines (48 loc) · 2.31 KB
/
Copy pathace_editor.install
File metadata and controls
57 lines (48 loc) · 2.31 KB
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
<?php
/**
* @file
* Install functions for the Ace Editor module.
*/
use Drupal\Component\Utility\DeprecationHelper;
use Drupal\Core\Extension\Requirement\RequirementSeverity;
/**
* Implements hook_install().
*/
function ace_editor_install() {
$lib_path = ace_editor_lib_path();
if (!$lib_path) {
\Drupal::messenger()->addMessage(t('The Ace library is missing. The module requires <a href="@link">vardot/ace</a>, so <code>composer require drupal/ace_editor</code> installs it at @path. On a site that is not managed with Composer, download a build from <a href="@upstream">ace-builds</a> and copy it under @libraries; the module uses the first ace.js it finds there.', [
'@link' => 'https://github.com/Vardot/ace',
'@upstream' => 'https://github.com/ajaxorg/ace-builds',
'@path' => '/libraries/ace/',
'@libraries' => '/libraries/',
]), 'warning');
}
else {
\Drupal::messenger()->addMessage(t('Ace library found at @location', ['@location' => $lib_path]));
}
}
/**
* Implements hook_requirements().
*/
function ace_editor_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$requirements['ace_editor']['title'] = t('Ace library');
$lib_path = ace_editor_lib_path();
if ($lib_path) {
$requirements['ace_editor']['value'] = t('Installed at @location', ['@location' => $lib_path]);
$requirements['ace_editor']['severity'] = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.2.0', fn() => RequirementSeverity::OK, fn() => REQUIREMENT_OK);
}
else {
$requirements['ace_editor']['value'] = t('Not installed');
$requirements['ace_editor']['severity'] = DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.2.0', fn() => RequirementSeverity::Error, fn() => REQUIREMENT_ERROR);
$requirements['ace_editor']['description'] = t('The module requires the <a href="@library">vardot/ace</a> library, which Composer installs at @location. Run <code>composer require drupal/ace_editor</code> to bring it in. On a site that is not managed with Composer, download a build from <a href="@url">ace-builds</a> into @location.', [
'@library' => 'https://github.com/Vardot/ace',
'@url' => 'https://github.com/ajaxorg/ace-builds',
'@location' => '/libraries/ace/',
]);
}
}
return $requirements;
}