protected function InstantArticleContentEntityNormalizer::entityViewDisplay in Facebook Instant Articles 8.2
Same name and namespace in other branches
- 3.x src/Normalizer/InstantArticleContentEntityNormalizer.php \Drupal\fb_instant_articles\Normalizer\InstantArticleContentEntityNormalizer::entityViewDisplay()
Helper function to get the fb_instant_articles entity view display object.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: Content entity being normalized.
array $context: Context array passed to the normalize method.
Return value
\Drupal\Core\Entity\Entity\EntityViewDisplay Default entity view display object with the mapping for the given entity.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
1 call to InstantArticleContentEntityNormalizer::entityViewDisplay()
File
- src/
Normalizer/ InstantArticleContentEntityNormalizer.php, line 170
Class
- InstantArticleContentEntityNormalizer
- Facebook Instant Articles content entity normalizer.
Namespace
Drupal\fb_instant_articles\NormalizerCode
protected function entityViewDisplay(ContentEntityInterface $entity, array $context) {
$fbia_display_id = $entity
->getEntityTypeId() . '.' . $entity
->bundle() . '.' . EntityViewDisplayEditForm::FBIA_VIEW_MODE;
$default_display_id = $entity
->getEntityTypeId() . '.' . $entity
->bundle() . '.default';
$storage = $this->entityTypeManager
->getStorage('entity_view_display');
/** @var \Drupal\Core\Entity\Entity\EntityViewDisplay $display */
// If there is a display passed via $context, use that one.
if (isset($context['entity_view_display'])) {
return $context['entity_view_display'];
}
elseif (isset($context['view_mode']) && ($display = $storage
->load($entity
->getEntityTypeId() . '.' . $entity
->bundle() . '.' . $context['view_mode']))) {
return $display;
}
elseif (($display = $storage
->load($fbia_display_id)) && $display
->status()) {
return $display;
}
elseif ($display = $storage
->load($default_display_id)) {
return $display;
}
}