Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / content_translation / content_translation.install
1 <?php
2
3 /**
4  * @file
5  * Installation functions for Content Translation module.
6  */
7
8 use \Drupal\Core\Url;
9
10 /**
11  * Implements hook_install().
12  */
13 function content_translation_install() {
14   // Assign a fairly low weight to ensure our implementation of
15   // hook_module_implements_alter() is run among the last ones.
16   module_set_weight('content_translation', 10);
17
18   // Translation works when at least two languages are added.
19   if (count(\Drupal::languageManager()->getLanguages()) < 2) {
20     $t_args = [
21       ':language_url' => Url::fromRoute('entity.configurable_language.collection')->toString()
22     ];
23     $message = t('This site has only a single language enabled. <a href=":language_url">Add at least one more language</a> in order to translate content.', $t_args);
24     drupal_set_message($message, 'warning');
25   }
26   // Point the user to the content translation settings.
27   $t_args = [
28     ':settings_url' => Url::fromRoute('language.content_settings_page')->toString()
29   ];
30   $message = t('<a href=":settings_url">Enable translation</a> for <em>content types</em>, <em>taxonomy vocabularies</em>, <em>accounts</em>, or any other element you wish to translate.', $t_args);
31   drupal_set_message($message, 'warning');
32 }
33
34 /**
35  * Rebuild the routes as the content translation routes have now new names.
36  */
37 function content_translation_update_8001() {
38   \Drupal::service('router.builder')->rebuild();
39 }
40
41 /**
42  * Clear field type plugin caches to fix image field translatability.
43  */
44 function content_translation_update_8002() {
45   \Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
46 }