You are here

public function BlazyEntityReferenceBase::buildElementExtra in Blazy 8.2

Build extra elements.

Overrides BlazyEntityMediaBase::buildElementExtra

File

src/Dejavu/BlazyEntityReferenceBase.php, line 26

Class

BlazyEntityReferenceBase
Base class for all entity reference formatters with field details.

Namespace

Drupal\blazy\Dejavu

Code

public function buildElementExtra(array &$element, $entity, $langcode) {
  parent::buildElementExtra($element, $entity, $langcode);
  $settings =& $element['settings'];

  // Layouts can be builtin, or field, if so configured.
  if (!empty($settings['layout'])) {
    $layout = $settings['layout'];
    if (strpos($layout, 'field_') !== FALSE && isset($entity->{$layout})) {
      $layout = $this
        ->blazyEntity()
        ->getFieldString($entity, $layout, $langcode);
    }
    $settings['layout'] = $layout;
  }

  // Classes, if so configured.
  if (!empty($settings['class']) && isset($entity->{$settings['class']})) {
    $settings['class'] = $this
      ->blazyEntity()
      ->getFieldString($entity, $settings['class'], $langcode);
  }
}