LanguageNegotiationMethodInterface.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Drupal\language;
  3. use Drupal\Core\Config\ConfigFactoryInterface;
  4. use Drupal\Core\Language\LanguageInterface;
  5. use Drupal\Core\Session\AccountInterface;
  6. use Symfony\Component\HttpFoundation\Request;
  7. /**
  8. * Interface for language negotiation classes.
  9. */
  10. interface LanguageNegotiationMethodInterface {
  11. /**
  12. * Injects the language manager.
  13. *
  14. * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
  15. * The language manager to be used to retrieve the language list and the
  16. * already negotiated languages.
  17. */
  18. public function setLanguageManager(ConfigurableLanguageManagerInterface $language_manager);
  19. /**
  20. * Injects the configuration factory.
  21. *
  22. * @param \Drupal\Core\Config\ConfigFactoryInterface $config
  23. * The configuration factory.
  24. */
  25. public function setConfig(ConfigFactoryInterface $config);
  26. /**
  27. * Injects the current user.
  28. *
  29. * @param \Drupal\Core\Session\AccountInterface $current_user
  30. * The current active user.
  31. */
  32. public function setCurrentUser(AccountInterface $current_user);
  33. /**
  34. * Performs language negotiation.
  35. *
  36. * @param \Symfony\Component\HttpFoundation\Request $request
  37. * (optional) The current request. Defaults to NULL if it has not been
  38. * initialized yet.
  39. *
  40. * @return string
  41. * A valid language code or FALSE if the negotiation was unsuccessful.
  42. */
  43. public function getLangcode(Request $request = NULL);
  44. /**
  45. * Notifies the plugin that the language code it returned has been accepted.
  46. *
  47. * @param \Drupal\Core\Language\LanguageInterface $language
  48. * The accepted language.
  49. */
  50. public function persist(LanguageInterface $language);
  51. }