composition.inc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use Drupal\Core\Render\Element;
  3. /**
  4. * Prepares variables for Composition templates.
  5. *
  6. * Default template: composition.html.twig.
  7. *
  8. * @param array $variables
  9. * An associative array containing:
  10. * - elements: An associative array containing the user information and any
  11. * - attributes: HTML attributes for the containing element.
  12. */
  13. function template_preprocess_composition(array &$vars) {
  14. // dpm($variables);
  15. // Fetch Composition Entity Object.
  16. /** @var \Drupal\edlp_studio\CompositionInterface $composition */
  17. $composition = $vars['elements']['#composition'];
  18. $vars['view_mode'] = $vars['elements']['#view_mode'];
  19. // $vars['name'] = $composition->getName();
  20. // unset($vars['elements']['name']);
  21. // $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
  22. $vars['url'] = $composition->url();
  23. $vars['attributes']['cid'] = $composition->id();
  24. $vars['attributes']['class'] = array('composition');
  25. // Helpful $content variable for templates.
  26. foreach (Element::children($vars['elements']) as $key) {
  27. $vars['content'][$key] = $vars['elements'][$key];
  28. }
  29. // dpm($vars);
  30. }