1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- use \Drupal\Core\Url;
- use \Drupal\Component\Utility\Unicode;
- function template_preprocess_edlp_compositions_list(&$vars){
- $vars['compositions'] = array (
- '#theme' => 'item_list',
- '#items' => [],
- );
- $i = 0;
- foreach($vars['composition_entities'] as $entity){
- // get the url
- $url = Url::fromRoute('entity.composition.canonical',
- ['composition' => $entity->id()], ['absolute' => TRUE]);
- // get the delete url
- $delete_url = Url::fromRoute('edlp_studio.composition_controller_action_ajax',
- ['action' => 'delete', 'cid'=>$entity->id()], ['absolute' => TRUE]);
- $title = $entity->getName();
- $vars['compositions']['#items'][] = array(
- 'compo_link' => array(
- '#title' => $title,
- '#type' => 'link',
- '#url' => $url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $url->getInternalPath(),
- 'cid' => $entity->id(),
- 'class' => ['composition-link', $i==0 ? 'is-active':''],
- 'title'=>$title,
- ),
- ),
- ),
- 'delete_link' => array(
- '#title' => t("delete"),
- '#type' => 'link',
- '#url' => $delete_url,
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $delete_url->getInternalPath(),
- 'cid' => $entity->id(),
- 'class' => ['delete-composition-link'],
- 'title'=> t('Delete @title', array('@title'=>$title)),
- ),
- ),
- )
- );
- $i++;
- }
- $vars['compositions']['#items'][] = array(
- '#title' => t('New composition'),
- '#type' => 'link',
- '#url' => $vars['new_composition_url'],
- '#options'=>array(
- 'attributes' => array(
- 'data-drupal-link-system-path' => $vars['new_composition_url']->getInternalPath(),
- 'class' => ['new-composition-link']
- ),
- ),
- );
- }
|