You are here

function commerce_order_local_tasks_alter in Commerce Core 8.2

Implements hook_local_tasks_alter().

Removes profile tabs for profile types managed through the address book tab.

File

modules/order/commerce_order.module, line 252
Defines the Order entity and associated features.

Code

function commerce_order_local_tasks_alter(&$definitions) {

  /** @var \Drupal\commerce_order\AddressBookInterface $address_book */
  $address_book = \Drupal::service('commerce_order.address_book');
  if (!$address_book
    ->hasUi()) {
    return;
  }
  $profile_types = $address_book
    ->loadTypes();
  foreach ($profile_types as $profile_type) {
    $derivative_key = 'profile.user_page:' . $profile_type
      ->id();
    if (isset($definitions[$derivative_key])) {
      unset($definitions[$derivative_key]);
    }
  }
}