You are here

function ds_test_ds_pre_render_alter in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 tests/modules/ds_test/ds_test.module \ds_test_ds_pre_render_alter()
  2. 8.2 tests/modules/ds_test/ds_test.module \ds_test_ds_pre_render_alter()
  3. 7.2 tests/ds_test.module \ds_test_ds_pre_render_alter()

Implements hook_ds_pre_render_alter().

File

tests/modules/ds_test/ds_test.module, line 111
Display Suite test module.

Code

function ds_test_ds_pre_render_alter(&$layout_render_array, array $context, array &$vars) {

  /** @var EntityInterface $entity */
  $entity = $context['entity'];
  if (isset($entity->title->value) && $entity->title->value === 'Alter me!') {
    $layout_render_array['left'][] = [
      '#markup' => 'cool!',
      '#weight' => 20,
    ];
  }
  if ($entity
    ->getEntityTypeId() == 'user') {
    $vars['attributes']['class'][] = 'entity-label-class-' . $entity
      ->label();
  }
}