ConfigMapperInterface.php 7.38 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\config_translation\ConfigMapperInterface.
 */

namespace Drupal\config_translation;

10
use Drupal\Core\Language\LanguageInterface;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\Routing\RouteCollection;
13 14 15 16 17 18 19 20 21 22 23 24 25 26

/**
 * Defines an interface for configuration mapper.
 */
interface ConfigMapperInterface {

  /**
   * Returns title of this translation page.
   *
   * @return string
   *   The page title.
   */
  public function getTitle();

27 28 29 30 31 32 33 34
  /**
   * Sets the route collection.
   *
   * @param \Symfony\Component\Routing\RouteCollection $collection
   *   The route collection.
   */
  public function setRouteCollection(RouteCollection $collection);

35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
  /**
   * Returns the name of the base route the mapper is attached to.
   *
   * @return string
   *   The name of the base route the mapper is attached to.
   */
  public function getBaseRouteName();

  /**
   * Returns the route parameters for the base route the mapper is attached to.
   *
   * @return array
   */
  public function getBaseRouteParameters();

  /**
   * Returns the base route object the mapper is attached to.
   *
   * @return \Symfony\Component\Routing\Route
   *   The base route object the mapper is attached to.
   */
  public function getBaseRoute();

  /**
   * Returns a processed path for the base route the mapper is attached to.
   *
   * @return string
   *   Processed path with placeholders replaced.
   */
  public function getBasePath();

  /**
   * Returns route name for the translation overview route.
   *
   * @return string
   *   Route name for the mapper.
   */
  public function getOverviewRouteName();

  /**
   * Returns the route parameters for the translation overview route.
   *
   * @return array
   */
  public function getOverviewRouteParameters();

  /**
   * Returns the route object for a translation overview route.
   *
   * @return \Symfony\Component\Routing\Route
   *   The route object for the translation page.
   */
  public function getOverviewRoute();

  /**
   * Returns a processed path for the translation overview route.
   *
   * @return string
   *   Processed path with placeholders replaced.
   */
  public function getOverviewPath();

  /**
   * Returns route name for the translation add form route.
   *
   * @return string
   *   Route name for the mapper.
   */
  public function getAddRouteName();

  /**
   * Returns the route parameters for the translation add form route.
   *
   * @return array
   */
  public function getAddRouteParameters();

  /**
   * Returns the route object for a translation add form route.
   *
   * @return \Symfony\Component\Routing\Route
   *   The route object for the translation page.
   */
  public function getAddRoute();

  /**
   * Returns route name for the translation edit form route.
   *
   * @return string
   *   Route name for the mapper.
   */
  public function getEditRouteName();

  /**
   * Returns the route parameters for the translation edit form route.
   *
   * @return array
   */
  public function getEditRouteParameters();

  /**
   * Returns the route object for a translation edit form route.
   *
   * @return \Symfony\Component\Routing\Route
   *   The route object for the translation page.
   */
  public function getEditRoute();

  /**
   * Returns route name for the translation deletion route.
   *
   * @return string
   *   Route name for the mapper.
   */
  public function getDeleteRouteName();

  /**
   * Returns the route parameters for the translation deletion route.
   *
   * @return array
   */
  public function getDeleteRouteParameters();

  /**
   * Returns the route object for the translation deletion route.
   *
   * @return \Symfony\Component\Routing\Route
   *   The route object for the translation page.
   */
  public function getDeleteRoute();

  /**
   * Returns an array of configuration names for the mapper.
   *
   * @return array
   *   An array of configuration names for the mapper.
   */
  public function getConfigNames();

  /**
   * Adds the given configuration name to the list of names.
   *
   * @param string $name
   *   Configuration name.
   */
  public function addConfigName($name);

  /**
   * Returns the weight of the mapper.
   *
   * @return int
   *   The weight of the mapper.
   */
  public function getWeight();

  /**
   * Returns an array with all configuration data.
   *
   * @return array
   *   Configuration data keyed by configuration names.
   */
  public function getConfigData();

  /**
   * Returns the original language code of the configuration.
   *
   * @throws \RuntimeException
   *   Throws an exception if the language codes in the config files don't
   *   match.
   */
  public function getLangcode();

  /**
   * Returns language object for the configuration.
   *
   * If the language of the configuration files is not a configured language on
   * the site and it is English, we return a dummy language object to represent
   * the built-in language.
   *
214
   * @return \Drupal\Core\Language\LanguageInterface
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
   *   A configured language object instance or a dummy English language object.
   *
   * @throws \RuntimeException
   *   Throws an exception if the language codes in the config files don't
   *   match.
   */
  public function getLanguageWithFallback();

  /**
   * Returns the name of the type of data the mapper encapsulates.
   *
   * @return string
   *   The name of the type of data the mapper encapsulates.
   */
  public function getTypeName();

  /**
   * Provides an array of information to build a list of operation links.
   *
   * @return array
   *   An associative array of operation link data for this list, keyed by
   *   operation name, containing the following key-value pairs:
   *   - title: The localized title of the operation.
   *   - href: The path for the operation.
   *   - options: An array of URL options for the path.
   *   - weight: The weight of this operation.
   */
  public function getOperations();

  /**
   * Returns the label of the type of data the mapper encapsulates.
   *
   * @return string
   *   The label of the type of data the mapper encapsulates.
   */
  public function getTypeLabel();

  /**
   * Checks that all pieces of this configuration mapper have a schema.
   *
   * @return bool
   *   TRUE if all of the elements have schema, FALSE otherwise.
   */
  public function hasSchema();

  /**
   * Checks that all pieces of this configuration mapper have translatables.
   *
   * @return bool
   *   TRUE if all of the configuration elements have translatables, FALSE
   *   otherwise.
   */
  public function hasTranslatable();

  /**
   * Checks whether there is already a translation for this mapper.
   *
272
   * @param \Drupal\Core\Language\LanguageInterface $language
273 274 275 276 277 278
   *   A language object.
   *
   * @return bool
   *   TRUE if any of the configuration elements have a translation in the
   *   given language, FALSE otherwise.
   */
279
  public function hasTranslation(LanguageInterface $language);
280 281 282 283

  /**
   * Populate the config mapper with request data.
   *
284 285
   * @todo Replace $request with RouteMatch https://www.drupal.org/node/2295255.
   *
286 287 288 289 290 291 292 293 294 295 296 297 298 299
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   Page request object.
   */
  public function populateFromRequest(Request $request);

  /**
   * Returns the name of the contextual link group to add contextual links to.
   *
   * @return string|null
   *   A contextual link group name or null if no link should be added.
   */
  public function getContextualLinkGroup();

}