comparison core/modules/jsonapi/jsonapi.install @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
1 <?php
2
3 /**
4 * @file
5 * Module install file.
6 */
7
8 /**
9 * Implements hook_install().
10 */
11 function jsonapi_install() {
12 $module_handler = \Drupal::moduleHandler();
13 $potential_conflicts = [
14 'content_translation',
15 'config_translation',
16 'language',
17 ];
18 $should_warn = array_reduce($potential_conflicts, function ($should_warn, $module_name) use ($module_handler) {
19 return $should_warn ?: $module_handler->moduleExists($module_name);
20 }, FALSE);
21 if ($should_warn) {
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.', [
23 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/translations',
24 ]));
25 }
26 }
27
28 /**
29 * Implements hook_requirements().
30 */
31 function jsonapi_requirements($phase) {
32 $requirements = [];
33 if ($phase === 'runtime') {
34 $module_handler = \Drupal::moduleHandler();
35 $potential_conflicts = [
36 'content_translation',
37 'config_translation',
38 'language',
39 ];
40 $should_warn = array_reduce($potential_conflicts, function ($should_warn, $module_name) use ($module_handler) {
41 return $should_warn ?: $module_handler->moduleExists($module_name);
42 }, FALSE);
43 if ($should_warn) {
44 $requirements['jsonapi_multilingual_support'] = [
45 'title' => t('JSON:API multilingual support'),
46 'value' => t('Limited'),
47 'severity' => REQUIREMENT_INFO,
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.', [
49 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/translations',
50 ]),
51 ];
52 }
53 $requirements['jsonapi_revision_support'] = [
54 'title' => t('JSON:API revision support'),
55 'value' => t('Limited'),
56 'severity' => REQUIREMENT_INFO,
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.', [
58 ':jsonapi-docs' => 'https://www.drupal.org/docs/8/modules/jsonapi/revisions',
59 ]),
60 ];
61
62 }
63 return $requirements;
64 }
65
66 /**
67 * Enable BC: default the new read-only mode to "off" on existing sites.
68 */
69 function jsonapi_update_8701() {
70 $config_factory = \Drupal::configFactory();
71 $jsonapi_settings = $config_factory->getEditable('jsonapi.settings');
72 $jsonapi_settings->set('read_only', FALSE)
73 ->save(TRUE);
74 }