You are here

function template_preprocess_profile_items in Profile 2 8

Implements hook_preprocess_HOOK() for profile templates.

File

./profile.module, line 240
Support for configurable user profiles.

Code

function template_preprocess_profile_items(&$variables) {
  if (count($variables['profile_items'])) {
    $variables['title'] = String::checkPlain($variables['type']);
    foreach ($variables['profile_items'] as $profile_item) {
      $variables['items'][] = entity_view($profile_item, 'default');
      if ($profile_item
        ->access('update')) {
        $variables['edit_links'][] = \Drupal::l(t('Edit'), new Url("entity.profile.edit_form", array(
          'user' => \Drupal::currentUser()
            ->id(),
          'profile_type' => $profile_item
            ->bundle(),
          'profile' => $profile_item
            ->id(),
        )));
      }
      if ($profile_item
        ->access('delete')) {
        $variables['delete_links'][] = \Drupal::l(t('Delete'), new Url("entity.profile.delete_form", array(
          'user' => \Drupal::currentUser()
            ->id(),
          'profile_type' => $profile_item
            ->bundle(),
          'profile' => $profile_item
            ->id(),
        )));
      }
    }
  }
}