Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / rest / src / RestServiceProvider.php
1 <?php
2
3 namespace Drupal\rest;
4
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\DefinitionDecorator;
11 use Symfony\Component\DependencyInjection\Reference;
12
13 /**
14  * Provides BC services.
15  *
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
18  * that module.
19  */
20 class RestServiceProvider implements ServiceProviderInterface {
21
22   /**
23    * {@inheritdoc}
24    */
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 DefinitionDecorator(new Reference('hal.link_manager'));
32       $service_definition->setClass(LinkManager::class);
33       $container->setDefinition('rest.link_manager', $service_definition);
34
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 DefinitionDecorator(new Reference('hal.link_manager.type'));
39       $service_definition->setClass(TypeLinkManager::class);
40       $container->setDefinition('rest.link_manager.type', $service_definition);
41
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 DefinitionDecorator(new Reference('hal.link_manager.relation'));
46       $service_definition->setClass(RelationLinkManager::class);
47       $container->setDefinition('rest.link_manager.relation', $service_definition);
48     }
49   }
50
51 }