public function FieldSettingsHelper::getEntityViewDisplay in AJAX Comments 8
Get the entity view display configuration for the commented entity.
Parameters
\Drupal\comment\CommentInterface $comment: The comment entity.
string $view_mode: The current view mode.
Return value
\Drupal\Core\Entity\Display\EntityDisplayInterface The entity view display configuration for the commented entity.
1 call to FieldSettingsHelper::getEntityViewDisplay()
- FieldSettingsHelper::getFieldFormatterFromComment in src/
FieldSettingsHelper.php - Get the active field formatter for a comment entity.
File
- src/
FieldSettingsHelper.php, line 57
Class
- FieldSettingsHelper
- Class FieldSettingsHelper.
Namespace
Drupal\ajax_commentsCode
public function getEntityViewDisplay(CommentInterface $comment, $view_mode = 'default') {
/** @var \Drupal\Core\Entity\ContentEntityInterface $commented_entity */
$commented_entity = $comment
->getCommentedEntity();
// Try to load the configuration entity for the entity's
// view display settings.
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $view_display */
$view_display = $this->entityTypeManager
->getStorage('entity_view_display')
->load($commented_entity
->getEntityTypeId() . '.' . $commented_entity
->bundle() . '.' . $view_mode);
// If there is no entity view display configuration for the provided
// view mode, fall back on the default view mode.
if (empty($view_display)) {
$view_display = $this->entityTypeManager
->getStorage('entity_view_display')
->load($commented_entity
->getEntityTypeId() . '.' . $commented_entity
->bundle() . '.default');
}
return $view_display;
}