serialization.install
Same filename in other branches
Update functions for the Serialization module.
File
-
core/
modules/ serialization/ serialization.install
View source
<?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>');
}
/**
* Enable BC for timestamp formatting: continue to return UNIX timestamps.
*/
function serialization_update_8401() {
$config_factory = \Drupal::configFactory();
$serialization_settings = $config_factory->getEditable('serialization.settings');
$serialization_settings->set('bc_timestamp_normalizer_unix', TRUE)
->save(TRUE);
}
Functions
Title | Deprecated | Summary |
---|---|---|
serialization_requirements | Implements hook_requirements(). | |
serialization_update_8301 | ||
serialization_update_8302 | Add serialization.settings::bc_primitives_as_strings configuration. | |
serialization_update_8401 | Enable BC for timestamp formatting: continue to return UNIX timestamps. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.