Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / templates / module / src / entity-storage.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{ module }}\{{ entity_class }}Storage.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{ module }};
9 {% endblock %}
10
11 {% block use_class %}
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;
16 {% endblock %}
17
18 {% block class_declaration %}
19 /**
20  * Defines the storage handler class for {{ label }} entities.
21  *
22  * This extends the base storage class, adding required special handling for
23  * {{ label }} entities.
24  *
25  * @ingroup {{ module }}
26  */
27 class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ entity_class }}StorageInterface {% endblock %}
28
29 {% block class_methods %}
30   /**
31    * {@inheritdoc}
32    */
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()]
37     )->fetchCol();
38   }
39
40   /**
41    * {@inheritdoc}
42    */
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()]
47     )->fetchCol();
48   }
49
50   /**
51    * {@inheritdoc}
52    */
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()])
55       ->fetchField();
56   }
57
58   /**
59    * {@inheritdoc}
60    */
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())
65       ->execute();
66   }
67 {% endblock %}