12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- use Drupal\Core\Render\Element;
- /**
- * Prepares variables for Composition templates.
- *
- * Default template: composition.html.twig.
- *
- * @param array $variables
- * An associative array containing:
- * - elements: An associative array containing the user information and any
- * - attributes: HTML attributes for the containing element.
- */
- function template_preprocess_composition(array &$vars) {
- // dpm($variables);
- // Fetch Composition Entity Object.
- /** @var \Drupal\edlp_studio\CompositionInterface $composition */
- $composition = $vars['elements']['#composition'];
- $vars['view_mode'] = $vars['elements']['#view_mode'];
- // $vars['name'] = $composition->getName();
- // unset($vars['elements']['name']);
- // $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
- $vars['url'] = $composition->url();
- $vars['attributes']['cid'] = $composition->id();
- $vars['attributes']['class'] = array('composition');
- // Helpful $content variable for templates.
- foreach (Element::children($vars['elements']) as $key) {
- $vars['content'][$key] = $vars['elements'][$key];
- }
- // dpm($vars);
- }
|