RestServiceProvider.php 2.0 KB

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