You are here

OrganizationStorage.php in Drupal PM (Project Management) 4.x

File

modules/pm_organization/src/OrganizationStorage.php
View source
<?php

namespace Drupal\pm_organization;

use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
use Drupal\Core\Session\AccountInterface;
use Drupal\pm_organization\Entity\OrganizationInterface;

/**
 * Defines the storage handler class for Organization entities.
 *
 * This extends the base storage class, adding required special handling for
 * Organization entities.
 *
 * @ingroup pm_organization
 */
class OrganizationStorage extends SqlContentEntityStorage implements OrganizationStorageInterface {

  /**
   * {@inheritdoc}
   */
  public function revisionIds(OrganizationInterface $entity) {
    return $this->database
      ->query('SELECT vid FROM {pm_organization_revision} WHERE id=:id ORDER BY vid', [
      ':id' => $entity
        ->id(),
    ])
      ->fetchCol();
  }

  /**
   * {@inheritdoc}
   */
  public function userRevisionIds(AccountInterface $account) {
    return $this->database
      ->query('SELECT vid FROM {pm_organization_field_revision} WHERE uid = :uid ORDER BY vid', [
      ':uid' => $account
        ->id(),
    ])
      ->fetchCol();
  }

}

Classes

Namesort descending Description
OrganizationStorage Defines the storage handler class for Organization entities.