function NodeStorage::updateType

Same name and namespace in other branches
  1. 9 core/modules/node/src/NodeStorage.php \Drupal\node\NodeStorage::updateType()
  2. 8.9.x core/modules/node/src/NodeStorage.php \Drupal\node\NodeStorage::updateType()
  3. 10 core/modules/node/src/NodeStorage.php \Drupal\node\NodeStorage::updateType()

Updates all nodes of one type to be of another type.

Parameters

string $old_type: The current node type of the nodes.

string $new_type: The new node type of the nodes.

Return value

int The number of nodes whose node type field was modified.

Overrides NodeStorageInterface::updateType

File

core/modules/node/src/NodeStorage.php, line 47

Class

NodeStorage
Defines the storage handler class for nodes.

Namespace

Drupal\node

Code

public function updateType($old_type, $new_type) {
  @trigger_error(__CLASS__ . "::" . __FUNCTION__ . " is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. See https://www.drupal.org/node/3515214", E_USER_DEPRECATED);
  return $this->database
    ->update($this->getBaseTable())
    ->fields([
    'type' => $new_type,
  ])
    ->condition('type', $old_type)
    ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.