You are here

public function MenuLinkWeightServiceProvider::alter in Menu Link Weight 8

Same name and namespace in other branches
  1. 8.2 src/MenuLinkWeightServiceProvider.php \Drupal\menu_link_weight\MenuLinkWeightServiceProvider::alter()

@inheritDoc

Overrides ServiceProviderBase::alter

File

src/MenuLinkWeightServiceProvider.php, line 18

Class

MenuLinkWeightServiceProvider
Overrides the menu.parent_form_selector service.

Namespace

Drupal\menu_link_weight

Code

public function alter(ContainerBuilder $container) {
  $settings = BootstrapConfigStorageFactory::get()
    ->read('menu_link_weight.settings');
  $modules = $container
    ->getParameter('container.modules');
  if (isset($settings['menu_parent_form_selector']) && $settings['menu_parent_form_selector'] === 'cshs' && isset($modules['cshs'])) {
    $defintion = $container
      ->getDefinition('menu.parent_form_selector');
    $defintion
      ->setClass(CshsMenuParentFormSelector::class);
  }
}