'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'] ), ), ); }