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