1 {% extends "base/class.php.twig" %}
4 \Drupal\{{ module }}\{{ entity_class }}Storage.
7 {% block namespace_class %}
8 namespace Drupal\{{ module }};
12 use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
13 use Drupal\Core\Session\AccountInterface;
14 use Drupal\Core\Language\LanguageInterface;
15 use Drupal\{{ module }}\Entity\{{ entity_class }}Interface;
18 {% block class_declaration %}
20 * Defines the storage handler class for {{ label }} entities.
22 * This extends the base storage class, adding required special handling for
23 * {{ label }} entities.
25 * @ingroup {{ module }}
27 class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ entity_class }}StorageInterface {% endblock %}
29 {% block class_methods %}
33 public function revisionIds({{ entity_class }}Interface $entity) {
34 return $this->database->query(
35 'SELECT vid FROM {{ '{'~entity_name~'_revision}' }} WHERE id=:id ORDER BY vid',
36 [':id' => $entity->id()]
43 public function userRevisionIds(AccountInterface $account) {
44 return $this->database->query(
45 'SELECT vid FROM {{ '{'~entity_name~'_field_revision}' }} WHERE uid = :uid ORDER BY vid',
46 [':uid' => $account->id()]
53 public function countDefaultLanguageRevisions({{ entity_class }}Interface $entity) {
54 return $this->database->query('SELECT COUNT(*) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()])
61 public function clearRevisionsLanguage(LanguageInterface $language) {
62 return $this->database->update('{{ entity_name }}_revision')
63 ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
64 ->condition('langcode', $language->getId())