Chris@18
|
1 <?php
|
Chris@18
|
2
|
Chris@18
|
3 /**
|
Chris@18
|
4 * @file
|
Chris@18
|
5 * Module install file.
|
Chris@18
|
6 */
|
Chris@18
|
7
|
Chris@18
|
8 /**
|
Chris@18
|
9 * Implements hook_install().
|
Chris@18
|
10 */
|
Chris@18
|
11 function jsonapi_install() {
|
Chris@18
|
12 $module_handler = \Drupal::moduleHandler();
|
Chris@18
|
13 $potential_conflicts = [
|
Chris@18
|
14 'content_translation',
|
Chris@18
|
15 'config_translation',
|
Chris@18
|
16 'language',
|
Chris@18
|
17 ];
|
Chris@18
|
18 $should_warn = array_reduce($potential_conflicts, function ($should_warn, $module_name) use ($module_handler) {
|
Chris@18
|
19 return $should_warn ?: $module_handler->moduleExists($module_name);
|
Chris@18
|
20 }, FALSE);
|
Chris@18
|
21 if ($should_warn) {
|
Chris@18
|
22 \Drupal::messenger()->addWarning(t('Some multilingual features currently do not work well with JSON:API. See the <a href=":jsonapi-docs">JSON:API multilingual support documentation</a> for more information on the current status of multilingual support.', [
|
Chris@18
|
23 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/translations',
|
Chris@18
|
24 ]));
|
Chris@18
|
25 }
|
Chris@18
|
26 }
|
Chris@18
|
27
|
Chris@18
|
28 /**
|
Chris@18
|
29 * Implements hook_requirements().
|
Chris@18
|
30 */
|
Chris@18
|
31 function jsonapi_requirements($phase) {
|
Chris@18
|
32 $requirements = [];
|
Chris@18
|
33 if ($phase === 'runtime') {
|
Chris@18
|
34 $module_handler = \Drupal::moduleHandler();
|
Chris@18
|
35 $potential_conflicts = [
|
Chris@18
|
36 'content_translation',
|
Chris@18
|
37 'config_translation',
|
Chris@18
|
38 'language',
|
Chris@18
|
39 ];
|
Chris@18
|
40 $should_warn = array_reduce($potential_conflicts, function ($should_warn, $module_name) use ($module_handler) {
|
Chris@18
|
41 return $should_warn ?: $module_handler->moduleExists($module_name);
|
Chris@18
|
42 }, FALSE);
|
Chris@18
|
43 if ($should_warn) {
|
Chris@18
|
44 $requirements['jsonapi_multilingual_support'] = [
|
Chris@18
|
45 'title' => t('JSON:API multilingual support'),
|
Chris@18
|
46 'value' => t('Limited'),
|
Chris@18
|
47 'severity' => REQUIREMENT_INFO,
|
Chris@18
|
48 'description' => t('Some multilingual features currently do not work well with JSON:API. See the <a href=":jsonapi-docs">JSON:API multilingual support documentation</a> for more information on the current status of multilingual support.', [
|
Chris@18
|
49 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/translations',
|
Chris@18
|
50 ]),
|
Chris@18
|
51 ];
|
Chris@18
|
52 }
|
Chris@18
|
53 $requirements['jsonapi_revision_support'] = [
|
Chris@18
|
54 'title' => t('JSON:API revision support'),
|
Chris@18
|
55 'value' => t('Limited'),
|
Chris@18
|
56 'severity' => REQUIREMENT_INFO,
|
Chris@18
|
57 'description' => t('Revision support is currently read-only and only for the "Content" and "Media" entity types in JSON:API. See the <a href=":jsonapi-docs">JSON:API revision support documentation</a> for more information on the current status of revision support.', [
|
Chris@18
|
58 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/revisions',
|
Chris@18
|
59 ]),
|
Chris@18
|
60 ];
|
Chris@18
|
61
|
Chris@18
|
62 }
|
Chris@18
|
63 return $requirements;
|
Chris@18
|
64 }
|
Chris@18
|
65
|
Chris@18
|
66 /**
|
Chris@18
|
67 * Enable BC: default the new read-only mode to "off" on existing sites.
|
Chris@18
|
68 */
|
Chris@18
|
69 function jsonapi_update_8701() {
|
Chris@18
|
70 $config_factory = \Drupal::configFactory();
|
Chris@18
|
71 $jsonapi_settings = $config_factory->getEditable('jsonapi.settings');
|
Chris@18
|
72 $jsonapi_settings->set('read_only', FALSE)
|
Chris@18
|
73 ->save(TRUE);
|
Chris@18
|
74 }
|