Issue #2068063 by timmillwood, Berdir, tduong, Manuel Garcia, nlisgo, yongt9412, esod, lauriii, jonathan1055, vijaycs85, yoroy, amit.drupal, tkoleary, ifrik, Bojhan, xjm, tstoeckler, amateescu: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button
2017-06-15 12:02:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Post update functions for Node.
|
|
|
|
*/
|
|
|
|
|
2023-12-21 23:17:04 +00:00
|
|
|
use Drupal\Core\Config\Entity\ConfigEntityUpdater;
|
|
|
|
use Drupal\node\NodeTypeInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts empty `description` and `help` in content types to NULL.
|
|
|
|
*/
|
|
|
|
function node_post_update_set_node_type_description_and_help_to_null(array &$sandbox): void {
|
|
|
|
\Drupal::classResolver(ConfigEntityUpdater::class)
|
|
|
|
->update($sandbox, 'node_type', function (NodeTypeInterface $node_type): bool {
|
|
|
|
// Content types' `help` and `description` fields must be stored as NULL
|
|
|
|
// at the config level if they are empty.
|
|
|
|
if (trim($node_type->getDescription()) === '') {
|
|
|
|
$node_type->set('description', NULL);
|
|
|
|
}
|
|
|
|
if (trim($node_type->getHelp()) === '') {
|
|
|
|
$node_type->set('help', NULL);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-30 10:23:57 +00:00
|
|
|
/**
|
2020-03-11 20:58:38 +00:00
|
|
|
* Implements hook_removed_post_updates().
|
2018-11-30 10:23:57 +00:00
|
|
|
*/
|
2020-03-11 20:58:38 +00:00
|
|
|
function node_removed_post_updates() {
|
|
|
|
return [
|
|
|
|
'node_post_update_configure_status_field_widget' => '9.0.0',
|
|
|
|
'node_post_update_node_revision_views_data' => '9.0.0',
|
2022-02-08 12:16:18 +00:00
|
|
|
'node_post_update_glossary_view_published' => '10.0.0',
|
|
|
|
'node_post_update_rebuild_node_revision_routes' => '10.0.0',
|
2022-08-11 12:02:30 +00:00
|
|
|
'node_post_update_modify_base_field_author_override' => '10.0.0',
|
2020-03-11 20:58:38 +00:00
|
|
|
];
|
2018-11-30 10:23:57 +00:00
|
|
|
}
|