You are here

public function ProvisionService::getProvisionFromEntity in LTI Tool Provider 8

Same name and namespace in other branches
  1. 2.x modules/lti_tool_provider_provision/src/Services/ProvisionService.php \Drupal\lti_tool_provider_provision\Services\ProvisionService::getProvisionFromEntity()

Parameters

EntityInterface $entity:

Return value

EntityInterface|null

Throws

InvalidPluginDefinitionException

PluginNotFoundException

File

modules/lti_tool_provider_provision/src/Services/ProvisionService.php, line 205

Class

ProvisionService

Namespace

Drupal\lti_tool_provider_provision\Services

Code

public function getProvisionFromEntity(EntityInterface $entity) : ?EntityInterface {
  $provision = $this->entityTypeManager
    ->getStorage('lti_tool_provider_provision')
    ->loadByProperties([
    'provision_type' => $entity
      ->getEntityTypeId(),
    'provision_bundle' => $entity
      ->bundle(),
    'provision_id' => $entity
      ->id(),
  ]);
  if (count($provision)) {
    return reset($provision);
  }
  return null;
}