_node_mass_update_helper
function _node_mass_update_helper
_node_mass_update_helper(NodeInterface$node, array $updates,$langcode= NULL)
Updates individual nodes when fewer than 10 are queued.
Parameters
\Drupal\node\NodeInterface $node: A node to update.
array $updates: Associative array of updates.
string $langcode: (optional) The language updates should be applied to. If none is specified all available languages are processed.
Return value
\Drupal\node\NodeInterface An updated node object.
See also
File
- core/modules/node/node.admin.inc, line 83
- Content administration and module settings user interface.
Code
function _node_mass_update_helper(NodeInterface $node, array $updates, $langcode = NULL) { $langcodes = isset($langcode) ? array($langcode) : array_keys($node->getTranslationLanguages()); // For efficiency manually save the original node before applying any changes. $node->original = clone $node; foreach ($langcodes as $langcode) { foreach ($updates as $name => $value) { $node->getTranslation($langcode)->$name = $value; } } $node->save(); return $node; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!node!node.admin.inc/function/_node_mass_update_helper/8.1.x