You are here

public function EntityLegalDocumentVersion::getAcceptances in Entity Legal 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Entity/EntityLegalDocumentVersion.php \Drupal\entity_legal\Entity\EntityLegalDocumentVersion::getAcceptances()
  2. 4.0.x src/Entity/EntityLegalDocumentVersion.php \Drupal\entity_legal\Entity\EntityLegalDocumentVersion::getAcceptances()

Get the acceptances for this entity legal document version.

Parameters

\Drupal\Core\Session\AccountInterface|null $account: The Drupal user account to check for, or get all acceptances if NULL.

Return value

array The acceptance entities keyed by acceptance id.

Overrides EntityLegalDocumentVersionInterface::getAcceptances

1 call to EntityLegalDocumentVersion::getAcceptances()
EntityLegalDocumentVersion::delete in src/Entity/EntityLegalDocumentVersion.php
Deletes an entity permanently.

File

src/Entity/EntityLegalDocumentVersion.php, line 164

Class

EntityLegalDocumentVersion
Defines the entity legal document version entity.

Namespace

Drupal\entity_legal\Entity

Code

public function getAcceptances(AccountInterface $account = NULL) {
  $query = \Drupal::entityQuery(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME)
    ->condition('document_version_name', $this
    ->id());
  if ($account) {
    $query
      ->condition('uid', $account
      ->id());
  }
  $results = $query
    ->execute();
  if (!empty($results)) {
    return \Drupal::entityTypeManager()
      ->getStorage(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME)
      ->loadMultiple($results);
  }
  return [];
}