summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/navigation/src/NavigationServiceProvider.php
blob: 6e9a87102816e41ec0f064f4dc580952fa91e7bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

declare(strict_types=1);

namespace Drupal\navigation;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Symfony\Component\DependencyInjection\Reference;

/**
 * Defines a service provider for the Navigation module.
 *
 * @internal
 */
final class NavigationServiceProvider implements ServiceProviderInterface {

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container): void {
    // If shortcuts module service is available, register our own service.
    if ($container->has('shortcut.lazy_builders')) {
      $container
        ->register('navigation.shortcut_lazy_builder', ShortcutLazyBuilder::class)
        ->addArgument(new Reference('shortcut.lazy_builders'));
    }

    // If Workspaces module service is available, register our own service.
    if ($container->has('workspaces.lazy_builders')) {
      $container
        ->register('navigation.workspaces_lazy_builders', WorkspacesLazyBuilder::class)
        ->addArgument(new Reference('workspaces.manager'));
    }
  }

}