You are here

public function AccessToken::getHost in Access unpublished 8

Gets the host of the access token.

Return value

\Drupal\Core\Entity\ContentEntityInterface|null The host entity or NULL.

Overrides AccessTokenInterface::getHost

File

src/Entity/AccessToken.php, line 279

Class

AccessToken
Defines the Access token entity.

Namespace

Drupal\access_unpublished\Entity

Code

public function getHost() {
  if ($this
    ->get('entity_type')->value && $this
    ->get('entity_id')->value) {
    try {
      return \Drupal::entityTypeManager()
        ->getStorage($this
        ->get('entity_type')->value)
        ->load($this
        ->get('entity_id')->value);
    } catch (\Exception $exception) {
      return NULL;
    }
  }
}