3 namespace Drupal\config_translation;
5 use Drupal\Core\Language\LanguageInterface;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Symfony\Component\Routing\RouteCollection;
10 * Defines an interface for configuration mapper.
12 interface ConfigMapperInterface {
15 * Returns title of this translation page.
20 public function getTitle();
23 * Sets the route collection.
25 * @param \Symfony\Component\Routing\RouteCollection $collection
26 * The route collection.
28 public function setRouteCollection(RouteCollection $collection);
31 * Returns the name of the base route the mapper is attached to.
34 * The name of the base route the mapper is attached to.
36 public function getBaseRouteName();
39 * Returns the route parameters for the base route the mapper is attached to.
43 public function getBaseRouteParameters();
46 * Returns the base route object the mapper is attached to.
48 * @return \Symfony\Component\Routing\Route
49 * The base route object the mapper is attached to.
51 public function getBaseRoute();
54 * Returns a processed path for the base route the mapper is attached to.
57 * Processed path with placeholders replaced.
59 public function getBasePath();
62 * Returns route name for the translation overview route.
65 * Route name for the mapper.
67 public function getOverviewRouteName();
70 * Returns the route parameters for the translation overview route.
74 public function getOverviewRouteParameters();
77 * Returns the route object for a translation overview route.
79 * @return \Symfony\Component\Routing\Route
80 * The route object for the translation page.
82 public function getOverviewRoute();
85 * Returns a processed path for the translation overview route.
88 * Processed path with placeholders replaced.
90 public function getOverviewPath();
93 * Returns route name for the translation add form route.
96 * Route name for the mapper.
98 public function getAddRouteName();
101 * Returns the route parameters for the translation add form route.
105 public function getAddRouteParameters();
108 * Returns the route object for a translation add form route.
110 * @return \Symfony\Component\Routing\Route
111 * The route object for the translation page.
113 public function getAddRoute();
116 * Returns route name for the translation edit form route.
119 * Route name for the mapper.
121 public function getEditRouteName();
124 * Returns the route parameters for the translation edit form route.
128 public function getEditRouteParameters();
131 * Returns the route object for a translation edit form route.
133 * @return \Symfony\Component\Routing\Route
134 * The route object for the translation page.
136 public function getEditRoute();
139 * Returns route name for the translation deletion route.
142 * Route name for the mapper.
144 public function getDeleteRouteName();
147 * Returns the route parameters for the translation deletion route.
151 public function getDeleteRouteParameters();
154 * Returns the route object for the translation deletion route.
156 * @return \Symfony\Component\Routing\Route
157 * The route object for the translation page.
159 public function getDeleteRoute();
162 * Returns an array of configuration names for the mapper.
165 * An array of configuration names for the mapper.
167 public function getConfigNames();
170 * Adds the given configuration name to the list of names.
172 * Note that it is the responsibility of the calling code to ensure that the
173 * configuration exists.
175 * @param string $name
176 * Configuration name.
178 public function addConfigName($name);
181 * Returns the weight of the mapper.
184 * The weight of the mapper.
186 public function getWeight();
189 * Returns an array with all configuration data.
192 * Configuration data keyed by configuration names.
194 public function getConfigData();
197 * Returns the original language code of the configuration.
199 * @throws \RuntimeException
200 * Throws an exception if the language codes in the config files don't
203 public function getLangcode();
206 * Returns the language code of a configuration object given its name.
208 * @param string $config_name
209 * The name of the configuration object.
212 * The language code of the configuration object.
214 public function getLangcodeFromConfig($config_name);
217 * Sets the original language code.
219 * @param string $langcode
224 public function setLangcode($langcode);
227 * Returns the name of the type of data the mapper encapsulates.
230 * The name of the type of data the mapper encapsulates.
232 public function getTypeName();
235 * Provides an array of information to build a list of operation links.
238 * An associative array of operation link data for this list, keyed by
239 * operation name, containing the following key-value pairs:
240 * - title: The localized title of the operation.
241 * - href: The path for the operation.
242 * - options: An array of URL options for the path.
243 * - weight: The weight of this operation.
245 public function getOperations();
248 * Returns the label of the type of data the mapper encapsulates.
251 * The label of the type of data the mapper encapsulates.
253 public function getTypeLabel();
256 * Checks that all pieces of this configuration mapper have a schema.
259 * TRUE if all of the elements have schema, FALSE otherwise.
261 public function hasSchema();
264 * Checks if pieces of this configuration mapper have translatables.
267 * TRUE if at least one of the configuration elements has translatables,
270 public function hasTranslatable();
273 * Checks whether there is already a translation for this mapper.
275 * @param \Drupal\Core\Language\LanguageInterface $language
279 * TRUE if any of the configuration elements have a translation in the
280 * given language, FALSE otherwise.
282 public function hasTranslation(LanguageInterface $language);
285 * Populate the config mapper with route match data.
287 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
290 * @see \Drupal\config_translation\Event\ConfigTranslationEvents::POPULATE_MAPPER
292 public function populateFromRouteMatch(RouteMatchInterface $route_match);
295 * Returns the name of the contextual link group to add contextual links to.
297 * @return string|null
298 * A contextual link group name or null if no link should be added.
300 public function getContextualLinkGroup();