You are here

protected function EntityHelperTrait::entityAuthor in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 src/Normalizer/EntityHelperTrait.php \Drupal\fb_instant_articles\Normalizer\EntityHelperTrait::entityAuthor()

Helper function to pull the author name out of an entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Content entity being normalized.

Return value

string|null Author name if there is one.

2 calls to EntityHelperTrait::entityAuthor()
InstantArticleContentEntityNormalizer::normalizeDefaultHeader in src/Normalizer/InstantArticleContentEntityNormalizer.php
Normalize the default header of the instant article.
InstantArticleRssContentEntityNormalizer::normalize in src/Normalizer/InstantArticleRssContentEntityNormalizer.php

File

src/Normalizer/EntityHelperTrait.php, line 93

Class

EntityHelperTrait
Common entity data getters shared between the normalizers.

Namespace

Drupal\fb_instant_articles\Normalizer

Code

protected function entityAuthor(ContentEntityInterface $entity) {

  // Default the article author to the username.
  if ($entity instanceof EntityOwnerInterface && ($owner = $entity
    ->getOwner())) {
    return $owner
      ->getDisplayName();
  }
}