PhotosImageStorage.php in Album Photos 6.0.x
File
src/PhotosImageStorage.php
View source
<?php
namespace Drupal\photos;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
class PhotosImageStorage extends SqlContentEntityStorage implements PhotosImageStorageInterface {
public function revisionIds(PhotosImageInterface $image) {
return $this->database
->query('SELECT vid FROM {' . $this
->getRevisionTable() . '} WHERE fid = :fid ORDER BY vid', [
':fid' => $image
->id(),
])
->fetchCol();
}
public function userRevisionIds(AccountInterface $account) {
return $this->database
->query('SELECT vid FROM {' . $this
->getRevisionDataTable() . '} WHERE uid = :uid ORDER BY vid', [
':uid' => $account
->id(),
])
->fetchCol();
}
public function countDefaultLanguageRevisions(PhotosImageInterface $image) {
return $this->database
->query('SELECT COUNT(*) FROM {' . $this
->getRevisionDataTable() . '} WHERE fid = :fid AND default_langcode = 1', [
':fid' => $image
->id(),
])
->fetchField();
}
public function updatePhotosAlbum(PhotosImageInterface $image, $new_album) {
return $this->database
->update($this
->getBaseTable())
->fields([
'album_id' => $new_album,
])
->condition('fid', $image
->id())
->execute();
}
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database
->update($this
->getRevisionTable())
->fields([
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
])
->condition('langcode', $language
->getId())
->execute();
}
}