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.
|
|
|
|
*/
|
|
|
|
|
2021-12-29 15:28:30 +00:00
|
|
|
use Drupal\Core\Field\Entity\BaseFieldOverride;
|
2021-03-23 10:22:03 +00:00
|
|
|
use Drupal\views\Entity\View;
|
|
|
|
|
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',
|
|
|
|
];
|
2018-11-30 10:23:57 +00:00
|
|
|
}
|
2021-03-23 10:22:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a published filter to the glossary View.
|
|
|
|
*/
|
|
|
|
function node_post_update_glossary_view_published() {
|
|
|
|
if (\Drupal::moduleHandler()->moduleExists('views')) {
|
|
|
|
$view = View::load('glossary');
|
|
|
|
if (!$view) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$display =& $view->getDisplay('default');
|
|
|
|
if (!isset($display['display_options']['filters']['status'])) {
|
|
|
|
$display['display_options']['filters']['status'] = [
|
|
|
|
'expose' => [
|
|
|
|
'operator' => '',
|
|
|
|
'operator_limit_selection' => FALSE,
|
|
|
|
'operator_list' => [],
|
|
|
|
],
|
|
|
|
'field' => 'status',
|
|
|
|
'group' => 1,
|
|
|
|
'id' => 'status',
|
|
|
|
'table' => 'node_field_data',
|
|
|
|
'value' => '1',
|
|
|
|
'plugin_id' => 'boolean',
|
|
|
|
'entity_type' => 'node',
|
|
|
|
'entity_field' => 'status',
|
|
|
|
];
|
|
|
|
$view->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
Issue #2730631 by jibran, benjifisher, claudiu.cristea, pdenooijer, merauluka, Deepak Goyal, mpp, gnuget, Spokje, sanjayk, idimopoulos, nikitagupta, ayushmishra206, ridhimaabrol24, mrinalini9, KapilV, harings_rob, Berdir, alexpott, catch, dawehner, tstoeckler, dpi, lexbritvin, mlncn, jhedstrom, kevin.dutra, amateescu, johnwebdev, Steven Spasbo: Upcast node and node_revision parameters of node revision routes
2021-05-11 20:35:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Rebuild the node revision routes.
|
|
|
|
*/
|
|
|
|
function node_post_update_rebuild_node_revision_routes() {
|
|
|
|
// Empty update to rebuild routes.
|
|
|
|
}
|
2021-12-29 15:28:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates stale references to Drupal\node\Entity\Node::getCurrentUserId.
|
|
|
|
*/
|
|
|
|
function node_post_update_modify_base_field_author_override() {
|
|
|
|
$uid_fields = \Drupal::entityTypeManager()
|
|
|
|
->getStorage('base_field_override')
|
|
|
|
->getQuery()
|
|
|
|
->condition('entity_type', 'node')
|
|
|
|
->condition('field_name', 'uid')
|
|
|
|
->condition('default_value_callback', 'Drupal\node\Entity\Node::getCurrentUserId')
|
|
|
|
->execute();
|
|
|
|
foreach (BaseFieldOverride::loadMultiple($uid_fields) as $base_field_override) {
|
|
|
|
$base_field_override->setDefaultValueCallback('Drupal\node\Entity\Node::getDefaultEntityOwner')->save();
|
|
|
|
}
|
|
|
|
}
|