You are here

public function EntityLegalDocumentVersionController::getAcceptances in Entity Legal 7

Same name and namespace in other branches
  1. 7.2 entity_legal.entity_controller.inc \EntityLegalDocumentVersionController::getAcceptances()

Get acceptances for the given version of this document.

Parameters

EntityLegalDocumentVersion $legal_document_entity_version: The legal document entity to get the acceptances of.

bool|object $account: The account the acceptance belongs to, or all accounts if not set.

Return value

array The acceptances associated with this legal document entity and account.

File

./entity_legal.entity_controller.inc, line 169
Entity API controller classes for entity_legal module.

Class

EntityLegalDocumentVersionController
Legal document version exportable controller.

Code

public function getAcceptances(EntityLegalDocumentVersion $legal_document_entity_version, $account = FALSE) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME)
    ->propertyCondition('document_version_name', $legal_document_entity_version->name);
  if ($account) {
    $query
      ->propertyCondition('uid', $account->uid);
  }
  $results = $query
    ->execute();
  if (!empty($results)) {
    $results = entity_load(ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME, array_keys($results[ENTITY_LEGAL_DOCUMENT_ACCEPTANCE_ENTITY_NAME]));
  }
  return $results;
}