LanguageNegotiationMethodBase.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /**
  7. * Base class for language negotiation methods.
  8. */
  9. abstract class LanguageNegotiationMethodBase implements LanguageNegotiationMethodInterface {
  10. /**
  11. * The language manager.
  12. *
  13. * @var \Drupal\Core\Language\LanguageManagerInterface
  14. */
  15. protected $languageManager;
  16. /**
  17. * The configuration factory.
  18. *
  19. * @var \Drupal\Core\Config\ConfigFactoryInterface
  20. */
  21. protected $config;
  22. /**
  23. * The current active user.
  24. *
  25. * @var \Drupal\Core\Session\AccountInterface
  26. */
  27. protected $currentUser;
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function setLanguageManager(ConfigurableLanguageManagerInterface $language_manager) {
  32. $this->languageManager = $language_manager;
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function setConfig(ConfigFactoryInterface $config) {
  38. $this->config = $config;
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function setCurrentUser(AccountInterface $current_user) {
  44. $this->currentUser = $current_user;
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function persist(LanguageInterface $language) {
  50. // Default implementation persists nothing.
  51. }
  52. }