5 use Drupal\Core\DependencyInjection\ContainerBuilder;
6 use Drupal\Core\DependencyInjection\ServiceProviderInterface;
7 use Drupal\rest\LinkManager\LinkManager;
8 use Drupal\rest\LinkManager\RelationLinkManager;
9 use Drupal\rest\LinkManager\TypeLinkManager;
10 use Symfony\Component\DependencyInjection\ChildDefinition;
11 use Symfony\Component\DependencyInjection\Reference;
14 * Provides BC services.
16 * These services are not added via rest.services.yml because the service
17 * classes extend classes from the HAL module. They also have no use without
20 class RestServiceProvider implements ServiceProviderInterface {
25 public function register(ContainerBuilder $container) {
26 $modules = $container->getParameter(('container.modules'));
27 if (isset($modules['hal'])) {
28 // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
29 // Use hal.link_manager instead.
30 // @see https://www.drupal.org/node/2830467
31 $service_definition = new ChildDefinition(new Reference('hal.link_manager'));
32 $service_definition->setClass(LinkManager::class);
33 $container->setDefinition('rest.link_manager', $service_definition);
35 // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
36 // Use hal.link_manager.type instead.
37 // @see https://www.drupal.org/node/2830467
38 $service_definition = new ChildDefinition(new Reference('hal.link_manager.type'));
39 $service_definition->setClass(TypeLinkManager::class);
40 $container->setDefinition('rest.link_manager.type', $service_definition);
42 // @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
43 // Use hal.link_manager.relation instead.
44 // @see https://www.drupal.org/node/2830467
45 $service_definition = new ChildDefinition(new Reference('hal.link_manager.relation'));
46 $service_definition->setClass(RelationLinkManager::class);
47 $container->setDefinition('rest.link_manager.relation', $service_definition);