ParamConverterManagerInterface.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace Drupal\Core\ParamConverter;
  3. use Symfony\Component\Routing\RouteCollection;
  4. /**
  5. * Provides an interface for a parameter converter manager.
  6. */
  7. interface ParamConverterManagerInterface {
  8. /**
  9. * Registers a parameter converter with the manager.
  10. *
  11. * @param \Drupal\Core\ParamConverter\ParamConverterInterface $param_converter
  12. * The added param converter instance.
  13. * @param string $id
  14. * The parameter converter service id to register.
  15. *
  16. * @return $this
  17. */
  18. public function addConverter(ParamConverterInterface $param_converter, $id);
  19. /**
  20. * Lazy-loads converter services.
  21. *
  22. * @param string $id
  23. * The service id of converter service to load.
  24. *
  25. * @return \Drupal\Core\ParamConverter\ParamConverterInterface
  26. * The loaded converter service identified by the given service id.
  27. *
  28. * @throws \InvalidArgumentException
  29. * If the given service id is not a registered converter.
  30. */
  31. public function getConverter($id);
  32. /**
  33. * Saves a list of applicable converters to each route.
  34. *
  35. * @param \Symfony\Component\Routing\RouteCollection $routes
  36. * A collection of routes to apply converters to.
  37. */
  38. public function setRouteParameterConverters(RouteCollection $routes);
  39. /**
  40. * Invokes the registered converter for each defined parameter on a route.
  41. *
  42. * @param array $defaults
  43. * The route defaults array.
  44. *
  45. * @return array
  46. * The modified defaults.
  47. *
  48. * @throws \Drupal\Core\ParamConverter\ParamNotConvertedException
  49. * If one of the assigned converters returned NULL because the given
  50. * variable could not be converted.
  51. */
  52. public function convert(array $defaults);
  53. }