function template_preprocess_apigee_entity in Apigee Edge 8
Prepares variables for Apigee entity templates.
Default template: apigee-entity.html.twig.
Parameters
array $variables: An associative array containing:
- elements: An array of elements to display in view mode.
File
- ./
apigee_edge.module, line 162 - Copyright 2018 Google Inc.
Code
function template_preprocess_apigee_entity(array &$variables) {
$variables['view_mode'] = $variables['elements']['#view_mode'];
/** @var \Drupal\apigee_edge\Entity\EdgeEntityInterface $entity */
$entity = $variables['entity'] = $variables['elements']['#entity'];
$variables['label'] = $entity
->label();
if (!$entity
->isNew() && $entity
->hasLinkTemplate('canonical')) {
$variables['url'] = $entity
->toUrl('canonical', [
'language' => $entity
->language(),
])
->toString();
}
// Helpful $content variable for templates.
$variables += [
'content' => [],
];
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}