You are here

protected function EntityHelperTrait::entityCreatedTime 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::entityCreatedTime()

Helper function to get the created time of the given entity if applicable.

Parameters

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

Return value

bool|\DateTime Created time of the given entity.

2 calls to EntityHelperTrait::entityCreatedTime()
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 63

Class

EntityHelperTrait
Common entity data getters shared between the normalizers.

Namespace

Drupal\fb_instant_articles\Normalizer

Code

protected function entityCreatedTime(ContentEntityInterface $entity) {
  if ($created = $entity
    ->get('created')) {
    return \DateTime::createFromFormat('U', $created->value);
  }
}