5 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\Core\Language\LanguageInterface;
10 * Defines the storage handler class for nodes.
12 * This extends the base storage class, adding required special handling for
15 class NodeStorage extends SqlContentEntityStorage implements NodeStorageInterface {
20 public function revisionIds(NodeInterface $node) {
21 return $this->database->query(
22 'SELECT vid FROM {node_revision} WHERE nid=:nid ORDER BY vid',
23 [':nid' => $node->id()]
30 public function userRevisionIds(AccountInterface $account) {
31 return $this->database->query(
32 'SELECT vid FROM {node_field_revision} WHERE uid = :uid ORDER BY vid',
33 [':uid' => $account->id()]
40 public function countDefaultLanguageRevisions(NodeInterface $node) {
41 return $this->database->query('SELECT COUNT(*) FROM {node_field_revision} WHERE nid = :nid AND default_langcode = 1', [':nid' => $node->id()])->fetchField();
47 public function updateType($old_type, $new_type) {
48 return $this->database->update('node')
49 ->fields(['type' => $new_type])
50 ->condition('type', $old_type)
57 public function clearRevisionsLanguage(LanguageInterface $language) {
58 return $this->database->update('node_revision')
59 ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
60 ->condition('langcode', $language->getId())