5b57a8717f13bc96e102ebd65d234e8fccb51872
[yaffs-website] / web / core / lib / Drupal / Core / TypedData / TranslatableInterface.php
1 <?php
2
3 namespace Drupal\Core\TypedData;
4
5 /**
6  * Interface for translatable data.
7  */
8 interface TranslatableInterface {
9
10   /**
11    * Returns the translation language.
12    *
13    * @return \Drupal\Core\Language\LanguageInterface
14    *   The language object.
15    */
16   public function language();
17
18   /**
19    * Checks whether the translation is the default one.
20    *
21    * @return bool
22    *   TRUE if the translation is the default one, FALSE otherwise.
23    */
24   public function isDefaultTranslation();
25
26   /**
27    * Checks whether the translation is new.
28    *
29    * @return bool
30    *   TRUE if the translation is new, FALSE otherwise.
31    */
32   public function isNewTranslation();
33
34   /**
35    * Returns the languages the data is translated to.
36    *
37    * @param bool $include_default
38    *   (optional) Whether the default language should be included. Defaults to
39    *   TRUE.
40    *
41    * @return \Drupal\Core\Language\LanguageInterface[]
42    *   An associative array of language objects, keyed by language codes.
43    */
44   public function getTranslationLanguages($include_default = TRUE);
45
46   /**
47    * Gets a translation of the data.
48    *
49    * The returned translation has to be of the same type than this typed data
50    * object.
51    *
52    * @param $langcode
53    *   The language code of the translation to get or
54    *   LanguageInterface::LANGCODE_DEFAULT
55    *   to get the data in default language.
56    *
57    * @return $this
58    *   A typed data object for the translated data.
59    *
60    * @throws \InvalidArgumentException
61    *   If an invalid or non-existing translation language is specified.
62    */
63   public function getTranslation($langcode);
64
65   /**
66    * Returns the translatable object referring to the original language.
67    *
68    * @return $this
69    *   The translation object referring to the original language.
70    */
71   public function getUntranslated();
72
73   /**
74    * Returns TRUE there is a translation for the given language code.
75    *
76    * @param string $langcode
77    *   The language code identifying the translation.
78    *
79    * @return bool
80    *   TRUE if the translation exists, FALSE otherwise.
81    */
82   public function hasTranslation($langcode);
83
84   /**
85    * Adds a new translation to the translatable object.
86    *
87    * @param string $langcode
88    *   The language code identifying the translation.
89    * @param array $values
90    *   (optional) An array of initial values to be assigned to the translatable
91    *   fields. Defaults to none.
92    *
93    * @return $this
94    *
95    * @throws \InvalidArgumentException
96    *   If an invalid or existing translation language is specified.
97    */
98   public function addTranslation($langcode, array $values = []);
99
100   /**
101    * Removes the translation identified by the given language code.
102    *
103    * @param string $langcode
104    *   The language code identifying the translation to be removed.
105    */
106   public function removeTranslation($langcode);
107
108   /**
109    * Returns the translation support status.
110    *
111    * @return bool
112    *   TRUE if the object has translation support enabled.
113    */
114   public function isTranslatable();
115
116 }