123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * @file
- * Update functions for the Serialization module.
- */
- /**
- * Implements hook_requirements().
- */
- function serialization_requirements($phase) {
- $requirements = [];
- if ($phase == 'runtime') {
- $requirements['serialization_as_strings'] = [
- 'title' => t('Serialized data types'),
- 'severity' => REQUIREMENT_INFO,
- ];
- if (\Drupal::config('serialization.settings')->get('bc_primitives_as_strings')) {
- $requirements['serialization_as_strings']['value'] = t('Enabled');
- $requirements['serialization_as_strings']['description'] = t('The Serialization API is configured to output only string values for REST and other applications (instead of integers or Booleans when appropriate). <a href="https://www.drupal.org/node/2837696">Disabling this backwards compatibility mode</a> is recommended unless your sites or applications require string output.');
- }
- else {
- $requirements['serialization_as_strings']['value'] = t('Not enabled');
- $requirements['serialization_as_strings']['description'] = t('The Serialization API is configured with the recommended default and outputs typed values (integers, Booleans, or strings as appropriate) for REST and other applications. If your site or applications require string output, you can <a href="https://www.drupal.org/node/2837696">enable backwards compatibility mode</a>.');
- }
- }
- return $requirements;
- }
- /**
- * @see hal_update_8301()
- */
- function serialization_update_8301() {}
- /**
- * Add serialization.settings::bc_primitives_as_strings configuration.
- */
- function serialization_update_8302() {
- $config_factory = \Drupal::configFactory();
- $config_factory->getEditable('serialization.settings')
- ->set('bc_primitives_as_strings', FALSE)
- ->save(TRUE);
- return t('The REST API will no longer output all values as strings. Integers/booleans will be used where appropriate. If your site depends on these value being strings, <a href="https://www.drupal.org/node/2837696">read the change record to learn how to enable the BC mode.</a>');
- }
|