SupportTicketStorage.php in Support Ticketing System 8
File
modules/support_ticket/src/SupportTicketStorage.php
View source
<?php
namespace Drupal\support_ticket;
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Language\LanguageInterface;
class SupportTicketStorage extends SqlContentEntityStorage implements SupportTicketStorageInterface {
public function revisionIds(SupportTicketInterface $support_ticket) {
return $this->database
->query('SELECT vid FROM {support_ticket_revision} WHERE stid=:stid ORDER BY vid', array(
':stid' => $support_ticket
->id(),
))
->fetchCol();
}
public function userRevisionIds(AccountInterface $account) {
return $this->database
->query('SELECT vid FROM {support_ticket_field_revision} WHERE uid = :uid ORDER BY vid', array(
':uid' => $account
->id(),
))
->fetchCol();
}
public function countDefaultLanguageRevisions(SupportTicketInterface $support_ticket) {
return $this->database
->query('SELECT COUNT(*) FROM {support_ticket_field_revision} WHERE stid = :stid AND default_langcode = 1', array(
':stid' => $support_ticket
->id(),
))
->fetchField();
}
public function updateType($old_type, $new_type) {
return $this->database
->update('support_ticket')
->fields(array(
'support_ticket_type' => $new_type,
))
->condition('support_ticket_type', $old_type)
->execute();
}
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database
->update('support_ticket_revision')
->fields(array(
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
))
->condition('langcode', $language
->getId())
->execute();
}
}