12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Drupal\heartbeat;
- use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
- use Drupal\Core\Session\AccountInterface;
- use Drupal\Core\Language\LanguageInterface;
- use Drupal\heartbeat\Entity\HeartbeatInterface;
- /**
- * Defines the storage handler class for Heartbeat entities.
- *
- * This extends the base storage class, adding required special handling for
- * Heartbeat entities.
- *
- * @ingroup heartbeat
- */
- class HeartbeatStorage extends SqlContentEntityStorage implements HeartbeatStorageInterface {
- /**
- * {@inheritdoc}
- */
- public function revisionIds(HeartbeatInterface $entity) {
- return $this->database->query(
- 'SELECT vid FROM {heartbeat_revision} WHERE id=:id ORDER BY vid',
- array(':id' => $entity->id())
- )->fetchCol();
- }
- /**
- * {@inheritdoc}
- */
- public function userRevisionIds(AccountInterface $account) {
- return $this->database->query(
- 'SELECT vid FROM {heartbeat_field_revision} WHERE uid = :uid ORDER BY vid',
- array(':uid' => $account->id())
- )->fetchCol();
- }
- /**
- * {@inheritdoc}
- */
- public function countDefaultLanguageRevisions(HeartbeatInterface $entity) {
- return $this->database->query('SELECT COUNT(*) FROM {heartbeat_field_revision} WHERE id = :id AND default_langcode = 1', array(':id' => $entity->id()))
- ->fetchField();
- }
- /**
- * {@inheritdoc}
- */
- public function clearRevisionsLanguage(LanguageInterface $language) {
- return $this->database->update('heartbeat_revision')
- ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))
- ->condition('langcode', $language->getId())
- ->execute();
- }
- }
|