Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -113,7 +113,7 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
/**
|
||||
* Gets the entity instance for this mapper.
|
||||
*
|
||||
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface $entity
|
||||
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface
|
||||
* The configuration entity.
|
||||
*/
|
||||
public function getEntity() {
|
||||
|
@ -165,7 +165,7 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBaseRouteParameters() {
|
||||
return array($this->entityType => $this->entity->id());
|
||||
return [$this->entityType => $this->entity->id()];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -220,14 +220,14 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOperations() {
|
||||
return array(
|
||||
'list' => array(
|
||||
return [
|
||||
'list' => [
|
||||
'title' => $this->t('List'),
|
||||
'url' => Url::fromRoute('config_translation.entity_list', [
|
||||
'mapper_id' => $this->getPluginId(),
|
||||
]),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -259,12 +259,12 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
|||
*/
|
||||
protected function processRoute(Route $route) {
|
||||
// Add entity upcasting information.
|
||||
$parameters = $route->getOption('parameters') ?: array();
|
||||
$parameters += array(
|
||||
$this->entityType => array(
|
||||
$parameters = $route->getOption('parameters') ?: [];
|
||||
$parameters += [
|
||||
$this->entityType => [
|
||||
'type' => 'entity:' . $this->entityType,
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$route->setOption('parameters', $parameters);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class ConfigFieldMapper extends ConfigEntityMapper {
|
|||
*/
|
||||
public function getTypeLabel() {
|
||||
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
|
||||
return $this->t('@label fields', array('@label' => $base_entity_info->getLabel()));
|
||||
return $this->t('@label fields', ['@label' => $base_entity_info->getLabel()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,12 +39,12 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $defaults = array(
|
||||
protected $defaults = [
|
||||
'title' => '',
|
||||
'names' => array(),
|
||||
'names' => [],
|
||||
'weight' => 20,
|
||||
'class' => '\Drupal\config_translation\ConfigNamesMapper',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructs a ConfigMapperManager.
|
||||
|
@ -72,7 +72,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
$this->alterInfo('config_translation_info');
|
||||
// Config translation only uses an info hook discovery, cache by language.
|
||||
$cache_key = 'config_translation_info_plugins' . ':' . $language_manager->getCurrentLanguage()->getId();
|
||||
$this->setCacheBackend($cache_backend, $cache_key, array('config_translation_info_plugins'));
|
||||
$this->setCacheBackend($cache_backend, $cache_key, ['config_translation_info_plugins']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
// request; when routes are being rebuilt at the end of the request,
|
||||
// this service only happens to get instantiated with the updated list
|
||||
// of installed themes.
|
||||
$directories = array();
|
||||
$directories = [];
|
||||
foreach ($this->moduleHandler->getModuleList() as $name => $module) {
|
||||
$directories[$name] = $module->getPath();
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMappers(RouteCollection $collection = NULL) {
|
||||
$mappers = array();
|
||||
$mappers = [];
|
||||
foreach ($this->getDefinitions() as $id => $definition) {
|
||||
$mappers[$id] = $this->createInstance($id);
|
||||
if ($collection) {
|
||||
|
@ -155,7 +155,7 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa
|
|||
// If this plugin was provided by a module that does not exist, remove the
|
||||
// plugin definition.
|
||||
foreach ($definitions as $plugin_id => $plugin_definition) {
|
||||
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
|
||||
if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], ['core', 'component']) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) {
|
||||
unset($definitions[$plugin_id]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBaseRouteParameters() {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -231,11 +231,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
public function getOverviewRoute() {
|
||||
$route = new Route(
|
||||
$this->getBaseRoute()->getPath() . '/translate',
|
||||
array(
|
||||
[
|
||||
'_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
|
||||
'plugin_id' => $this->getPluginId(),
|
||||
),
|
||||
array('_config_translation_overview_access' => 'TRUE')
|
||||
],
|
||||
['_config_translation_overview_access' => 'TRUE']
|
||||
);
|
||||
$this->processRoute($route);
|
||||
return $route;
|
||||
|
@ -272,11 +272,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
public function getAddRoute() {
|
||||
$route = new Route(
|
||||
$this->getBaseRoute()->getPath() . '/translate/{langcode}/add',
|
||||
array(
|
||||
[
|
||||
'_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm',
|
||||
'plugin_id' => $this->getPluginId(),
|
||||
),
|
||||
array('_config_translation_form_access' => 'TRUE')
|
||||
],
|
||||
['_config_translation_form_access' => 'TRUE']
|
||||
);
|
||||
$this->processRoute($route);
|
||||
return $route;
|
||||
|
@ -302,11 +302,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
public function getEditRoute() {
|
||||
$route = new Route(
|
||||
$this->getBaseRoute()->getPath() . '/translate/{langcode}/edit',
|
||||
array(
|
||||
[
|
||||
'_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm',
|
||||
'plugin_id' => $this->getPluginId(),
|
||||
),
|
||||
array('_config_translation_form_access' => 'TRUE')
|
||||
],
|
||||
['_config_translation_form_access' => 'TRUE']
|
||||
);
|
||||
$this->processRoute($route);
|
||||
return $route;
|
||||
|
@ -332,11 +332,11 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
public function getDeleteRoute() {
|
||||
$route = new Route(
|
||||
$this->getBaseRoute()->getPath() . '/translate/{langcode}/delete',
|
||||
array(
|
||||
[
|
||||
'_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm',
|
||||
'plugin_id' => $this->getPluginId(),
|
||||
),
|
||||
array('_config_translation_form_access' => 'TRUE')
|
||||
],
|
||||
['_config_translation_form_access' => 'TRUE']
|
||||
);
|
||||
$this->processRoute($route);
|
||||
return $route;
|
||||
|
@ -413,7 +413,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigData() {
|
||||
$config_data = array();
|
||||
$config_data = [];
|
||||
foreach ($this->getConfigNames() as $name) {
|
||||
$config_data[$name] = $this->configFactory->getEditable($name)->get();
|
||||
}
|
||||
|
@ -467,12 +467,12 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOperations() {
|
||||
return array(
|
||||
'translate' => array(
|
||||
return [
|
||||
'translate' => [
|
||||
'title' => $this->t('Translate'),
|
||||
'url' => Url::fromRoute($this->getOverviewRouteName(), $this->getOverviewRouteParameters()),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $themes = array();
|
||||
protected $themes = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -58,20 +58,20 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
|
|||
$theme = $entity->getTheme();
|
||||
$plugin_definition = $entity->getPlugin()->getPluginDefinition();
|
||||
|
||||
$row['label'] = array(
|
||||
$row['label'] = [
|
||||
'data' => $entity->label(),
|
||||
'class' => 'table-filter-text-source',
|
||||
);
|
||||
];
|
||||
|
||||
$row['theme'] = array(
|
||||
$row['theme'] = [
|
||||
'data' => $this->themes[$theme]->info['name'],
|
||||
'class' => 'table-filter-text-source',
|
||||
);
|
||||
];
|
||||
|
||||
$row['category'] = array(
|
||||
$row['category'] = [
|
||||
'data' => $plugin_definition['category'],
|
||||
'class' => 'table-filter-text-source',
|
||||
);
|
||||
];
|
||||
|
||||
$row['operations']['data'] = $this->buildOperations($entity);
|
||||
|
||||
|
@ -93,7 +93,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function sortRows($a, $b) {
|
||||
return $this->sortRowsMultiple($a, $b, array('theme', 'category', 'label'));
|
||||
return $this->sortRowsMultiple($a, $b, ['theme', 'category', 'label']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -134,12 +134,12 @@ class ConfigTranslationController extends ControllerBase {
|
|||
$mapper = $this->configMapperManager->createInstance($plugin_id);
|
||||
$mapper->populateFromRouteMatch($route_match);
|
||||
|
||||
$page = array();
|
||||
$page['#title'] = $this->t('Translations for %label', array('%label' => $mapper->getTitle()));
|
||||
$page = [];
|
||||
$page['#title'] = $this->t('Translations for %label', ['%label' => $mapper->getTitle()]);
|
||||
|
||||
$languages = $this->languageManager->getLanguages();
|
||||
if (count($languages) == 1) {
|
||||
drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', array(':url' => $this->url('entity.configurable_language.collection'))), 'warning');
|
||||
drupal_set_message($this->t('In order to translate configuration, the website must have at least two <a href=":url">languages</a>.', [':url' => $this->url('entity.configurable_language.collection')]), 'warning');
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -172,7 +172,7 @@ class ConfigTranslationController extends ControllerBase {
|
|||
// If the language is not configured on the site, create a dummy language
|
||||
// object for this listing only to ensure the user gets useful info.
|
||||
$language_name = $this->languageManager->getLanguageName($original_langcode);
|
||||
$languages[$original_langcode] = new Language(array('id' => $original_langcode, 'name' => $language_name));
|
||||
$languages[$original_langcode] = new Language(['id' => $original_langcode, 'name' => $language_name]);
|
||||
}
|
||||
|
||||
// We create a fake request object to pass into
|
||||
|
@ -181,10 +181,10 @@ class ConfigTranslationController extends ControllerBase {
|
|||
// possible nor performant.
|
||||
$fake_request = $request->duplicate();
|
||||
|
||||
$page['languages'] = array(
|
||||
$page['languages'] = [
|
||||
'#type' => 'table',
|
||||
'#header' => array($this->t('Language'), $this->t('Operations')),
|
||||
);
|
||||
'#header' => [$this->t('Language'), $this->t('Operations')],
|
||||
];
|
||||
foreach ($languages as $language) {
|
||||
$langcode = $language->getId();
|
||||
|
||||
|
@ -198,57 +198,57 @@ class ConfigTranslationController extends ControllerBase {
|
|||
// Prepare the language name and the operations depending on whether this
|
||||
// is the original language or not.
|
||||
if ($langcode == $original_langcode) {
|
||||
$language_name = '<strong>' . $this->t('@language (original)', array('@language' => $language->getName())) . '</strong>';
|
||||
$language_name = '<strong>' . $this->t('@language (original)', ['@language' => $language->getName()]) . '</strong>';
|
||||
|
||||
// Check access for the path/route for editing, so we can decide to
|
||||
// include a link to edit or not.
|
||||
$edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account);
|
||||
|
||||
// Build list of operations.
|
||||
$operations = array();
|
||||
$operations = [];
|
||||
if ($edit_access) {
|
||||
$operations['edit'] = array(
|
||||
$operations['edit'] = [
|
||||
'title' => $this->t('Edit'),
|
||||
'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$language_name = $language->getName();
|
||||
|
||||
$operations = array();
|
||||
$operations = [];
|
||||
// If no translation exists for this language, link to add one.
|
||||
if (!$mapper->hasTranslation($language)) {
|
||||
$operations['add'] = array(
|
||||
$operations['add'] = [
|
||||
'title' => $this->t('Add'),
|
||||
'url' => Url::fromRoute($mapper->getAddRouteName(), $mapper->getAddRouteParameters()),
|
||||
);
|
||||
];
|
||||
}
|
||||
else {
|
||||
// Otherwise, link to edit the existing translation.
|
||||
$operations['edit'] = array(
|
||||
$operations['edit'] = [
|
||||
'title' => $this->t('Edit'),
|
||||
'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters()),
|
||||
);
|
||||
];
|
||||
|
||||
$operations['delete'] = array(
|
||||
$operations['delete'] = [
|
||||
'title' => $this->t('Delete'),
|
||||
'url' => Url::fromRoute($mapper->getDeleteRouteName(), $mapper->getDeleteRouteParameters()),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$page['languages'][$langcode]['language'] = array(
|
||||
$page['languages'][$langcode]['language'] = [
|
||||
'#markup' => $language_name,
|
||||
);
|
||||
];
|
||||
|
||||
$page['languages'][$langcode]['operations'] = array(
|
||||
$page['languages'][$langcode]['operations'] = [
|
||||
'#type' => 'operations',
|
||||
'#links' => $operations,
|
||||
// Even if the mapper contains multiple language codes, the source
|
||||
// configuration can still be edited.
|
||||
'#access' => ($langcode == $original_langcode) || $operations_access,
|
||||
);
|
||||
];
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
|
|
|
@ -16,10 +16,10 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
|
|||
* @return array
|
||||
*/
|
||||
protected function getFilterLabels() {
|
||||
return array(
|
||||
return [
|
||||
'placeholder' => $this->t('Enter label'),
|
||||
'description' => $this->t('Enter a part of the label or description to filter by.'),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,28 +29,28 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
|
|||
$build = parent::render();
|
||||
$filter = $this->getFilterLabels();
|
||||
|
||||
usort($build['table']['#rows'], array($this, 'sortRows'));
|
||||
usort($build['table']['#rows'], [$this, 'sortRows']);
|
||||
|
||||
$build['filters'] = array(
|
||||
$build['filters'] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter', 'js-show'),
|
||||
),
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter', 'js-show'],
|
||||
],
|
||||
'#weight' => -10,
|
||||
);
|
||||
];
|
||||
|
||||
$build['filters']['text'] = array(
|
||||
$build['filters']['text'] = [
|
||||
'#type' => 'search',
|
||||
'#title' => $this->t('Search'),
|
||||
'#size' => 30,
|
||||
'#placeholder' => $filter['placeholder'],
|
||||
'#attributes' => array(
|
||||
'class' => array('table-filter-text'),
|
||||
'#attributes' => [
|
||||
'class' => ['table-filter-text'],
|
||||
'data-table' => '.config-translation-entity-list',
|
||||
'autocomplete' => 'off',
|
||||
'title' => $filter['description'],
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$build['table']['#attributes']['class'][] = 'config-translation-entity-list';
|
||||
$build['table']['#weight'] = 0;
|
||||
|
@ -95,7 +95,7 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function sortRows($a, $b) {
|
||||
return $this->sortRowsMultiple($a, $b, array('label'));
|
||||
return $this->sortRowsMultiple($a, $b, ['label']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,14 +26,14 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $baseEntityInfo = array();
|
||||
protected $baseEntityInfo = [];
|
||||
|
||||
/**
|
||||
* The bundle info for the base entity type.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $baseEntityBundles = array();
|
||||
protected $baseEntityBundles = [];
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
|
@ -99,8 +99,8 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
|||
$bundle = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle');
|
||||
$bundle = Unicode::strtolower($bundle);
|
||||
|
||||
$info['placeholder'] = $this->t('Enter field or @bundle', array('@bundle' => $bundle));
|
||||
$info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', array('@bundle' => $bundle));
|
||||
$info['placeholder'] = $this->t('Enter field or @bundle', ['@bundle' => $bundle]);
|
||||
$info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', ['@bundle' => $bundle]);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
@ -109,17 +109,17 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
$row['label'] = array(
|
||||
$row['label'] = [
|
||||
'data' => $entity->label(),
|
||||
'class' => 'table-filter-text-source',
|
||||
);
|
||||
];
|
||||
|
||||
if ($this->displayBundle()) {
|
||||
$bundle = $entity->get('bundle');
|
||||
$row['bundle'] = array(
|
||||
$row['bundle'] = [
|
||||
'data' => $this->baseEntityBundles[$bundle]['label'],
|
||||
'class' => 'table-filter-text-source',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $row + parent::buildRow($entity);
|
||||
|
@ -165,7 +165,7 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function sortRows($a, $b) {
|
||||
return $this->sortRowsMultiple($a, $b, array('bundle', 'label'));
|
||||
return $this->sortRowsMultiple($a, $b, ['bundle', 'label']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ class ConfigTranslationMapperList extends ControllerBase {
|
|||
* Renderable array with config translation mappers.
|
||||
*/
|
||||
public function render() {
|
||||
$build = array(
|
||||
$build = [
|
||||
'#type' => 'table',
|
||||
'#header' => $this->buildHeader(),
|
||||
'#rows' => array(),
|
||||
);
|
||||
'#rows' => [],
|
||||
];
|
||||
|
||||
$mappers = array();
|
||||
$mappers = [];
|
||||
|
||||
foreach ($this->mappers as $mapper) {
|
||||
if ($row = $this->buildRow($mapper)) {
|
||||
|
@ -120,10 +120,10 @@ class ConfigTranslationMapperList extends ControllerBase {
|
|||
// Retrieve and sort operations.
|
||||
$operations = $mapper->getOperations();
|
||||
uasort($operations, 'Drupal\Component\Utility\SortArray::sortByWeightElement');
|
||||
$build = array(
|
||||
$build = [
|
||||
'#type' => 'operations',
|
||||
'#links' => $operations,
|
||||
);
|
||||
];
|
||||
return $build;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ class ConfigTranslationAddForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) {
|
||||
$form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode);
|
||||
$form['#title'] = $this->t('Add @language translation for %label', array(
|
||||
$form['#title'] = $this->t('Add @language translation for %label', [
|
||||
'%label' => $this->mapper->getTitle(),
|
||||
'@language' => $this->language->getName(),
|
||||
));
|
||||
]);
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ConfigTranslationAddForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::submitForm($form, $form_state);
|
||||
drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->getName())));
|
||||
drupal_set_message($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()));
|
||||
return $this->t('Are you sure you want to delete the @language translation of %label?', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,7 +140,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
|||
$cache_backend->deleteAll();
|
||||
}
|
||||
|
||||
drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName())));
|
||||
drupal_set_message($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
|
||||
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
|
|
@ -22,10 +22,10 @@ class ConfigTranslationEditForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) {
|
||||
$form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode);
|
||||
$form['#title'] = $this->t('Edit @language translation for %label', array(
|
||||
$form['#title'] = $this->t('Edit @language translation for %label', [
|
||||
'%label' => $this->mapper->getTitle(),
|
||||
'@language' => $this->language->getName(),
|
||||
));
|
||||
]);
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class ConfigTranslationEditForm extends ConfigTranslationFormBase {
|
|||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::submitForm($form, $form_state);
|
||||
drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->getName())));
|
||||
drupal_set_message($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $baseConfigData = array();
|
||||
protected $baseConfigData = [];
|
||||
|
||||
/**
|
||||
* Constructs a ConfigTranslationFormBase.
|
||||
|
@ -164,26 +164,26 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
// Even though this is a nested form, we do not set #tree to TRUE because
|
||||
// the form value structure is generated by using #parents for each element.
|
||||
// @see \Drupal\config_translation\FormElement\FormElementBase::getElements()
|
||||
$form['config_names'] = array('#type' => 'container');
|
||||
$form['config_names'] = ['#type' => 'container'];
|
||||
foreach ($this->mapper->getConfigNames() as $name) {
|
||||
$form['config_names'][$name] = array('#type' => 'container');
|
||||
$form['config_names'][$name] = ['#type' => 'container'];
|
||||
|
||||
$schema = $this->typedConfigManager->get($name);
|
||||
$source_config = $this->baseConfigData[$name];
|
||||
$translation_config = $this->configFactory()->get($name)->get();
|
||||
|
||||
if ($form_element = $this->createFormElement($schema)) {
|
||||
$parents = array('config_names', $name);
|
||||
$parents = ['config_names', $name];
|
||||
$form['config_names'][$name] += $form_element->getTranslationBuild($this->sourceLanguage, $this->language, $source_config, $translation_config, $parents);
|
||||
}
|
||||
}
|
||||
|
||||
$form['actions']['#type'] = 'actions';
|
||||
$form['actions']['submit'] = array(
|
||||
$form['actions']['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => $this->t('Save translation'),
|
||||
'#button_type' => 'primary',
|
||||
);
|
||||
];
|
||||
|
||||
// Set the configuration language back.
|
||||
$this->languageManager->setConfigOverrideLanguage($original_language);
|
||||
|
@ -195,7 +195,7 @@ abstract class ConfigTranslationFormBase extends FormBase implements BaseFormIdI
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_values = $form_state->getValue(array('translation', 'config_names'));
|
||||
$form_values = $form_state->getValue(['translation', 'config_names']);
|
||||
|
||||
foreach ($this->mapper->getConfigNames() as $name) {
|
||||
$schema = $this->typedConfigManager->get($name);
|
||||
|
|
|
@ -16,7 +16,7 @@ class DateFormat extends FormElementBase {
|
|||
/** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */
|
||||
$date_formatter = \Drupal::service('date.formatter');
|
||||
$description = $this->t('A user-defined date format. See the <a href="http://php.net/manual/function.date.php">PHP manual</a> for available options.');
|
||||
$format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)));
|
||||
$format = $this->t('Displayed as %date_format', ['%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)]);
|
||||
|
||||
return [
|
||||
'#type' => 'textfield',
|
||||
|
|
|
@ -64,8 +64,8 @@ abstract class FormElementBase implements ElementInterface {
|
|||
$build['source'] = $this->getSourceElement($source_language, $source_config);
|
||||
$build['translation'] = $this->getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
|
||||
$build['source']['#parents'] = array_merge(array('source'), $parents);
|
||||
$build['translation']['#parents'] = array_merge(array('translation'), $parents);
|
||||
$build['source']['#parents'] = array_merge(['source'], $parents);
|
||||
$build['translation']['#parents'] = array_merge(['translation'], $parents);
|
||||
return $build;
|
||||
}
|
||||
|
||||
|
@ -93,15 +93,15 @@ abstract class FormElementBase implements ElementInterface {
|
|||
$value = $this->t('(Empty)');
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'item',
|
||||
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
|
||||
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@source_language' => $source_language->getName(),
|
||||
)),
|
||||
]),
|
||||
'#markup' => $value,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,15 +157,15 @@ abstract class FormElementBase implements ElementInterface {
|
|||
*/
|
||||
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
// Add basic properties that apply to all form elements.
|
||||
return array(
|
||||
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', array(
|
||||
return [
|
||||
'#title' => $this->t('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@source_language' => $translation_language->getName(),
|
||||
)),
|
||||
]),
|
||||
'#default_value' => $translation_config,
|
||||
'#attributes' => array('lang' => $translation_language->getId()),
|
||||
);
|
||||
'#attributes' => ['lang' => $translation_language->getId()],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,14 +46,14 @@ class ListElement implements ElementInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) {
|
||||
$build = array();
|
||||
$build = [];
|
||||
foreach ($this->element as $key => $element) {
|
||||
$sub_build = array();
|
||||
$sub_build = [];
|
||||
$element_key = isset($base_key) ? "$base_key.$key" : $key;
|
||||
$definition = $element->getDataDefinition();
|
||||
|
||||
if ($form_element = ConfigTranslationFormBase::createFormElement($element)) {
|
||||
$element_parents = array_merge($parents, array($key));
|
||||
$element_parents = array_merge($parents, [$key]);
|
||||
$sub_build += $form_element->getTranslationBuild($source_language, $translation_language, $source_config[$key], $translation_config[$key], $element_parents, $element_key);
|
||||
|
||||
if (empty($sub_build)) {
|
||||
|
@ -62,13 +62,13 @@ class ListElement implements ElementInterface {
|
|||
|
||||
// Build the sub-structure and include it with a wrapper in the form if
|
||||
// there are any translatable elements there.
|
||||
$build[$key] = array();
|
||||
$build[$key] = [];
|
||||
if ($element instanceof TraversableTypedDataInterface) {
|
||||
$build[$key] = array(
|
||||
$build[$key] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->getGroupTitle($definition, $sub_build),
|
||||
'#open' => empty($base_key),
|
||||
);
|
||||
];
|
||||
}
|
||||
$build[$key] += $sub_build;
|
||||
}
|
||||
|
|
|
@ -18,25 +18,25 @@ class PluralVariants extends FormElementBase {
|
|||
protected function getSourceElement(LanguageInterface $source_language, $source_config) {
|
||||
$plurals = $this->getNumberOfPlurals($source_language->getId());
|
||||
$values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', array(
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@source_language' => $source_language->getName(),
|
||||
)),
|
||||
]),
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
];
|
||||
for ($i = 0; $i < $plurals; $i++) {
|
||||
$element[$i] = array(
|
||||
$element[$i] = [
|
||||
'#type' => 'item',
|
||||
// @todo Should use better labels https://www.drupal.org/node/2499639
|
||||
'#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
|
||||
'#markup' => SafeMarkup::format('<span lang="@langcode">@value</span>', array(
|
||||
'#markup' => SafeMarkup::format('<span lang="@langcode">@value</span>', [
|
||||
'@langcode' => $source_language->getId(),
|
||||
'@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
|
||||
)),
|
||||
);
|
||||
]),
|
||||
];
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
@ -47,23 +47,23 @@ class PluralVariants extends FormElementBase {
|
|||
protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
$plurals = $this->getNumberOfPlurals($translation_language->getId());
|
||||
$values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', array(
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', [
|
||||
// Labels originate from configuration schema and are translatable.
|
||||
'@label' => $this->t($this->definition->getLabel()),
|
||||
'@translation_language' => $translation_language->getName(),
|
||||
)),
|
||||
]),
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
];
|
||||
for ($i = 0; $i < $plurals; $i++) {
|
||||
$element[$i] = array(
|
||||
$element[$i] = [
|
||||
'#type' => 'textfield',
|
||||
// @todo Should use better labels https://www.drupal.org/node/2499639
|
||||
'#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'),
|
||||
'#default_value' => isset($values[$i]) ? $values[$i] : '',
|
||||
'#attributes' => array('lang' => $translation_language->getId()),
|
||||
);
|
||||
'#attributes' => ['lang' => $translation_language->getId()],
|
||||
];
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
|
|
@ -16,25 +16,25 @@ class TextFormat extends FormElementBase {
|
|||
// Instead of the formatted output show a disabled textarea. This allows for
|
||||
// easier side-by-side comparison, especially with formats with text
|
||||
// editors.
|
||||
return $this->getTranslationElement($source_language, $source_config, $source_config) + array(
|
||||
return $this->getTranslationElement($source_language, $source_config, $source_config) + [
|
||||
'#value' => $source_config['value'],
|
||||
'#disabled' => TRUE,
|
||||
'#allow_focus' => TRUE,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'text_format',
|
||||
// Override the #default_value property from the parent class.
|
||||
'#default_value' => $translation_config['value'],
|
||||
'#format' => $translation_config['format'],
|
||||
// @see \Drupal\config_translation\Element\FormElementBase::getTranslationElement()
|
||||
'#allowed_formats' => array($source_config['format']),
|
||||
) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
'#allowed_formats' => [$source_config['format']],
|
||||
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@ class Textarea extends FormElementBase {
|
|||
$rows_newlines = substr_count($translation_config, "\n" ) + 1;
|
||||
$rows = max($rows_words, $rows_newlines);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'textarea',
|
||||
'#rows' => $rows,
|
||||
) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@ class Textfield extends FormElementBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
return array(
|
||||
return [
|
||||
'#type' => 'textfield',
|
||||
) + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
] + parent::getTranslationElement($translation_language, $source_config, $translation_config);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
|
|||
// storing the title on the plugin definition for the link) because it
|
||||
// contains translated parts that we need in the runtime language.
|
||||
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', array('@type_name' => $type_name));
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
|
|||
// storing the title on the plugin definition for the link) because
|
||||
// it contains translated parts that we need in the runtime language.
|
||||
$type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', array('@type_name' => $type_name));
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* i18n strings profile field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_i18n_profile_field",
|
||||
* source_provider = "i18n"
|
||||
* )
|
||||
*/
|
||||
class I18nProfileField extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_fields', 'pf')
|
||||
->fields('pf', ['fid', 'name'])
|
||||
->fields('i18n', ['property'])
|
||||
->fields('lt', ['lid', 'translation', 'language']);
|
||||
$query->leftJoin('i18n_strings', 'i18n', 'i18n.objectid = pf.name');
|
||||
$query->leftJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'fid' => $this->t('Profile field ID.'),
|
||||
'lid' => $this->t('Locales target language ID.'),
|
||||
'language' => $this->t('Language for this field.'),
|
||||
'translation' => $this->t('Translation of either the title or explanation.'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
$ids['language']['type'] = 'string';
|
||||
$ids['lid']['type'] = 'integer';
|
||||
$ids['lid']['alias'] = 'lt';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -48,7 +48,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
|||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
// Come after field_ui.
|
||||
$events[RoutingEvents::ALTER] = array('onAlterRoutes', -110);
|
||||
$events[RoutingEvents::ALTER] = ['onAlterRoutes', -110];
|
||||
return $events;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests the content translation behaviours on date formats.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationDateFormatUiTest extends WebTestBase {
|
||||
|
||||
public static $modules = array(
|
||||
'language',
|
||||
'config_translation',
|
||||
'system'
|
||||
);
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Enable additional languages.
|
||||
$langcodes = ['de', 'es'];
|
||||
foreach ($langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
|
||||
$user = $this->drupalCreateUser(array(
|
||||
'administer site configuration',
|
||||
'translate configuration',
|
||||
));
|
||||
$this->drupalLogin($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests date format translation behaviour.
|
||||
*/
|
||||
public function testDateFormatUI() {
|
||||
$this->drupalGet('admin/config/regional/date-time');
|
||||
|
||||
// Assert translation link unlocked date format.
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate');
|
||||
|
||||
// Assert translation link locked date format.
|
||||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate');
|
||||
|
||||
// Date pattern is visible on unlocked date formats.
|
||||
$this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add');
|
||||
$this->assertField('translation[config_names][core.date_format.medium][pattern]');
|
||||
|
||||
// Date pattern is not visible on locked date formats.
|
||||
$this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add');
|
||||
$this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]');
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ class ConfigTranslationFormTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('config_translation', 'config_translation_test', 'editor');
|
||||
public static $modules = ['config_translation', 'config_translation_test', 'editor'];
|
||||
|
||||
/**
|
||||
* The plugin ID of the mapper to test.
|
||||
|
@ -40,7 +40,7 @@ class ConfigTranslationFormTest extends WebTestBase {
|
|||
$this->pluginId = key($definitions);
|
||||
|
||||
$this->langcode = 'xx';
|
||||
ConfigurableLanguage::create(array('id' => $this->langcode, 'label' => 'XX'))->save();
|
||||
ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save();
|
||||
|
||||
\Drupal::state()->set('config_translation_test_alter_form_alter', TRUE);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ ENDPO;
|
|||
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language'));
|
||||
|
||||
$edit = [
|
||||
'modules[Multilingual][config_translation][enable]' => TRUE,
|
||||
'modules[config_translation][enable]' => TRUE,
|
||||
];
|
||||
$this->drupalPostForm('admin/modules', $edit, t('Install'));
|
||||
|
||||
|
|
|
@ -1,504 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\block_content\Entity\BlockContentType;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\shortcut\Entity\ShortcutSet;
|
||||
use Drupal\contact\Entity\ContactForm;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
||||
/**
|
||||
* Visit all lists.
|
||||
*
|
||||
* @group config_translation
|
||||
* @see \Drupal\config_translation\Tests\ConfigTranslationViewListUiTest
|
||||
*/
|
||||
class ConfigTranslationListUiTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array(
|
||||
'block',
|
||||
'config_translation',
|
||||
'contact',
|
||||
'block_content',
|
||||
'field',
|
||||
'field_ui',
|
||||
'menu_ui',
|
||||
'node',
|
||||
'shortcut',
|
||||
'taxonomy',
|
||||
'image',
|
||||
'responsive_image',
|
||||
'toolbar',
|
||||
);
|
||||
|
||||
/**
|
||||
* Admin user with all needed permissions.
|
||||
*
|
||||
* @var \Drupal\user\Entity\User
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$permissions = array(
|
||||
'access site-wide contact form',
|
||||
'administer blocks',
|
||||
'administer contact forms',
|
||||
'administer content types',
|
||||
'administer block_content fields',
|
||||
'administer filters',
|
||||
'administer menu',
|
||||
'administer node fields',
|
||||
'administer permissions',
|
||||
'administer shortcuts',
|
||||
'administer site configuration',
|
||||
'administer taxonomy',
|
||||
'administer account settings',
|
||||
'administer languages',
|
||||
'administer image styles',
|
||||
'administer responsive images',
|
||||
'translate configuration',
|
||||
);
|
||||
|
||||
// Create and log in user.
|
||||
$this->adminUser = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Enable import of translations. By default this is disabled for automated
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->save();
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the block listing for the translate operation.
|
||||
*
|
||||
* There are no blocks placed in the testing profile. Add one, then check
|
||||
* for Translate operation.
|
||||
*/
|
||||
protected function doBlockListTest() {
|
||||
// Add a test block, any block will do.
|
||||
// Set the machine name so the translate link can be built later.
|
||||
$id = Unicode::strtolower($this->randomMachineName(16));
|
||||
$this->drupalPlaceBlock('system_powered_by_block', array('id' => $id));
|
||||
|
||||
// Get the Block listing.
|
||||
$this->drupalGet('admin/structure/block');
|
||||
|
||||
$translate_link = 'admin/structure/block/manage/' . $id . '/translate';
|
||||
// Test if the link to translate the block is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the menu listing for the translate operation.
|
||||
*/
|
||||
protected function doMenuListTest() {
|
||||
// Create a test menu to decouple looking for translate operations link so
|
||||
// this does not test more than necessary.
|
||||
$this->drupalGet('admin/structure/menu/add');
|
||||
// Lowercase the machine name.
|
||||
$menu_name = Unicode::strtolower($this->randomMachineName(16));
|
||||
$label = $this->randomMachineName(16);
|
||||
$edit = array(
|
||||
'id' => $menu_name,
|
||||
'description' => '',
|
||||
'label' => $label,
|
||||
);
|
||||
// Create the menu by posting the form.
|
||||
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
|
||||
|
||||
// Get the Menu listing.
|
||||
$this->drupalGet('admin/structure/menu');
|
||||
|
||||
$translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';
|
||||
// Test if the link to translate the menu is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Check if the Link is not added if you are missing 'translate
|
||||
// configuration' permission.
|
||||
$permissions = array(
|
||||
'administer menu',
|
||||
);
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
|
||||
// Get the Menu listing.
|
||||
$this->drupalGet('admin/structure/menu');
|
||||
|
||||
$translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';
|
||||
// Test if the link to translate the menu is NOT on the page.
|
||||
$this->assertNoLinkByHref($translate_link);
|
||||
|
||||
// Log in as Admin again otherwise the rest will fail.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the vocabulary listing for the translate operation.
|
||||
*/
|
||||
protected function doVocabularyListTest() {
|
||||
// Create a test vocabulary to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => Unicode::strtolower($this->randomMachineName()),
|
||||
]);
|
||||
$vocabulary->save();
|
||||
|
||||
// Get the Taxonomy listing.
|
||||
$this->drupalGet('admin/structure/taxonomy');
|
||||
|
||||
$translate_link = 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/translate';
|
||||
// Test if the link to translate the vocabulary is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the custom block listing for the translate operation.
|
||||
*/
|
||||
public function doCustomContentTypeListTest() {
|
||||
// Create a test custom block type to decouple looking for translate
|
||||
// operations link so this does not test more than necessary.
|
||||
$block_content_type = BlockContentType::create(array(
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
'revision' => FALSE
|
||||
));
|
||||
$block_content_type->save();
|
||||
|
||||
// Get the custom block type listing.
|
||||
$this->drupalGet('admin/structure/block/block-content/types');
|
||||
|
||||
$translate_link = 'admin/structure/block/block-content/manage/' . $block_content_type->id() . '/translate';
|
||||
// Test if the link to translate the custom block type is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the contact forms listing for the translate operation.
|
||||
*/
|
||||
public function doContactFormsListTest() {
|
||||
// Create a test contact form to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$contact_form = ContactForm::create([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
]);
|
||||
$contact_form->save();
|
||||
|
||||
// Get the contact form listing.
|
||||
$this->drupalGet('admin/structure/contact');
|
||||
|
||||
$translate_link = 'admin/structure/contact/manage/' . $contact_form->id() . '/translate';
|
||||
// Test if the link to translate the contact form is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the content type listing for the translate operation.
|
||||
*/
|
||||
public function doContentTypeListTest() {
|
||||
// Create a test content type to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$content_type = $this->drupalCreateContentType(array(
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
|
||||
// Get the content type listing.
|
||||
$this->drupalGet('admin/structure/types');
|
||||
|
||||
$translate_link = 'admin/structure/types/manage/' . $content_type->id() . '/translate';
|
||||
// Test if the link to translate the content type is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the formats listing for the translate operation.
|
||||
*/
|
||||
public function doFormatsListTest() {
|
||||
// Create a test format to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$filter_format = FilterFormat::create(array(
|
||||
'format' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
$filter_format->save();
|
||||
|
||||
// Get the format listing.
|
||||
$this->drupalGet('admin/config/content/formats');
|
||||
|
||||
$translate_link = 'admin/config/content/formats/manage/' . $filter_format->id() . '/translate';
|
||||
// Test if the link to translate the format is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the shortcut listing for the translate operation.
|
||||
*/
|
||||
public function doShortcutListTest() {
|
||||
// Create a test shortcut to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$shortcut = ShortcutSet::create(array(
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomString(),
|
||||
));
|
||||
$shortcut->save();
|
||||
|
||||
// Get the shortcut listing.
|
||||
$this->drupalGet('admin/config/user-interface/shortcut');
|
||||
|
||||
$translate_link = 'admin/config/user-interface/shortcut/manage/' . $shortcut->id() . '/translate';
|
||||
// Test if the link to translate the shortcut is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the role listing for the translate operation.
|
||||
*/
|
||||
public function doUserRoleListTest() {
|
||||
// Create a test role to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$role_id = Unicode::strtolower($this->randomMachineName(16));
|
||||
$this->drupalCreateRole(array(), $role_id);
|
||||
|
||||
// Get the role listing.
|
||||
$this->drupalGet('admin/people/roles');
|
||||
|
||||
$translate_link = 'admin/people/roles/manage/' . $role_id . '/translate';
|
||||
// Test if the link to translate the role is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the language listing for the translate operation.
|
||||
*/
|
||||
public function doLanguageListTest() {
|
||||
// Create a test language to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
ConfigurableLanguage::createFromLangcode('ga')->save();
|
||||
|
||||
// Get the language listing.
|
||||
$this->drupalGet('admin/config/regional/language');
|
||||
|
||||
$translate_link = 'admin/config/regional/language/edit/ga/translate';
|
||||
// Test if the link to translate the language is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the image style listing for the translate operation.
|
||||
*/
|
||||
public function doImageStyleListTest() {
|
||||
// Get the image style listing.
|
||||
$this->drupalGet('admin/config/media/image-styles');
|
||||
|
||||
$translate_link = 'admin/config/media/image-styles/manage/medium/translate';
|
||||
// Test if the link to translate the style is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the responsive image mapping listing for the translate operation.
|
||||
*/
|
||||
public function doResponsiveImageListTest() {
|
||||
$edit = array();
|
||||
$edit['label'] = $this->randomMachineName();
|
||||
$edit['id'] = strtolower($edit['label']);
|
||||
$edit['fallback_image_style'] = 'thumbnail';
|
||||
|
||||
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
|
||||
$this->assertRaw(t('Responsive image style %label saved.', array('%label' => $edit['label'])));
|
||||
|
||||
// Get the responsive image style listing.
|
||||
$this->drupalGet('admin/config/media/responsive-image-style');
|
||||
|
||||
$translate_link = 'admin/config/media/responsive-image-style/' . $edit['id'] . '/translate';
|
||||
// Test if the link to translate the style is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the field listing for the translate operation.
|
||||
*/
|
||||
public function doFieldListTest() {
|
||||
// Create a base content type.
|
||||
$content_type = $this->drupalCreateContentType(array(
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
|
||||
// Create a block content type.
|
||||
$block_content_type = BlockContentType::create(array(
|
||||
'id' => 'basic',
|
||||
'label' => 'Basic',
|
||||
'revision' => FALSE
|
||||
));
|
||||
$block_content_type->save();
|
||||
$field = FieldConfig::create([
|
||||
// The field storage is guaranteed to exist because it is supplied by the
|
||||
// block_content module.
|
||||
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
|
||||
'bundle' => $block_content_type->id(),
|
||||
'label' => 'Body',
|
||||
'settings' => array('display_summary' => FALSE),
|
||||
]);
|
||||
$field->save();
|
||||
|
||||
// Look at a few fields on a few entity types.
|
||||
$pages = array(
|
||||
array(
|
||||
'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields',
|
||||
'field' => 'node.' . $content_type->id() . '.body',
|
||||
),
|
||||
array(
|
||||
'list' => 'admin/structure/block/block-content/manage/basic/fields',
|
||||
'field' => 'block_content.basic.body',
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($pages as $values) {
|
||||
// Get fields listing.
|
||||
$this->drupalGet($values['list']);
|
||||
|
||||
$translate_link = $values['list'] . '/' . $values['field'] . '/translate';
|
||||
// Test if the link to translate the field is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the date format listing for the translate operation.
|
||||
*/
|
||||
public function doDateFormatListTest() {
|
||||
// Get the date format listing.
|
||||
$this->drupalGet('admin/config/regional/date-time');
|
||||
|
||||
$translate_link = 'admin/config/regional/date-time/formats/manage/long/translate';
|
||||
// Test if the link to translate the format is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a given settings page for the translate operation.
|
||||
*
|
||||
* @param string $link
|
||||
* URL of the settings page to test.
|
||||
*/
|
||||
public function doSettingsPageTest($link) {
|
||||
// Get the settings page.
|
||||
$this->drupalGet($link);
|
||||
|
||||
$translate_link = $link . '/translate';
|
||||
// Test if the link to translate the settings page is present.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if translate link is added to operations in all configuration lists.
|
||||
*/
|
||||
public function testTranslateOperationInListUi() {
|
||||
// All lists based on paths provided by the module.
|
||||
$this->doBlockListTest();
|
||||
$this->doMenuListTest();
|
||||
$this->doVocabularyListTest();
|
||||
$this->doCustomContentTypeListTest();
|
||||
$this->doContactFormsListTest();
|
||||
$this->doContentTypeListTest();
|
||||
$this->doFormatsListTest();
|
||||
$this->doShortcutListTest();
|
||||
$this->doUserRoleListTest();
|
||||
$this->doLanguageListTest();
|
||||
$this->doImageStyleListTest();
|
||||
$this->doResponsiveImageListTest();
|
||||
$this->doDateFormatListTest();
|
||||
$this->doFieldListTest();
|
||||
|
||||
// Views is tested in Drupal\config_translation\Tests\ConfigTranslationViewListUiTest
|
||||
|
||||
// Test the maintenance settings page.
|
||||
$this->doSettingsPageTest('admin/config/development/maintenance');
|
||||
// Test the site information settings page.
|
||||
$this->doSettingsPageTest('admin/config/system/site-information');
|
||||
// Test the account settings page.
|
||||
$this->doSettingsPageTest('admin/config/people/accounts');
|
||||
// Test the RSS settings page.
|
||||
$this->doSettingsPageTest('admin/config/services/rss-publishing');
|
||||
}
|
||||
|
||||
}
|
|
@ -35,7 +35,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = array('fr', 'ta');
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* String translation storage object.
|
||||
|
@ -46,7 +46,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$permissions = array(
|
||||
$permissions = [
|
||||
'translate configuration',
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
|
@ -54,7 +54,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
'access site-wide contact form',
|
||||
'access contextual links',
|
||||
'administer views',
|
||||
);
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
|
||||
|
@ -83,17 +83,17 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
$labels = array(
|
||||
$labels = [
|
||||
'&$nxd~i0',
|
||||
'some "label" with quotes',
|
||||
$this->randomString(),
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($labels as $label) {
|
||||
$test_entity = entity_create('config_test', array(
|
||||
$test_entity = entity_create('config_test', [
|
||||
'id' => $this->randomMachineName(),
|
||||
'label' => $label,
|
||||
));
|
||||
]);
|
||||
$test_entity->save();
|
||||
|
||||
$base_url = 'admin/structure/config_test/manage/' . $test_entity->id();
|
||||
|
@ -119,7 +119,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
$this->drupalGet($base_url);
|
||||
$this->assertLink(t('Translate @title', array('@title' => $entity_type->getLowercaseLabel())));
|
||||
$this->assertLink(t('Translate @title', ['@title' => $entity_type->getLowercaseLabel()]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,10 +154,10 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
|
||||
|
||||
// Set up an override.
|
||||
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array(
|
||||
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [
|
||||
'value' => $overridden_label,
|
||||
'required' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->writeSettings($settings);
|
||||
|
||||
// Test that the overridden label is loaded with the entity.
|
||||
|
|
|
@ -48,7 +48,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = array('fr', 'ta');
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
|
@ -157,13 +157,13 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertRaw($site_slogan);
|
||||
|
||||
// Update site name and slogan for French.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][system.site][name]' => $fr_site_name,
|
||||
'translation[config_names][system.site][slogan]' => $fr_site_slogan,
|
||||
);
|
||||
];
|
||||
|
||||
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
|
||||
$this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French')));
|
||||
$this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
|
||||
|
||||
// Check for edit, delete links (and no 'add' link) for French language.
|
||||
$this->assertNoLinkByHref("$translation_base_url/fr/add");
|
||||
|
@ -189,18 +189,18 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertText($site_slogan);
|
||||
|
||||
// Translate 'Site name' label in French.
|
||||
$search = array(
|
||||
$search = [
|
||||
'string' => $site_name_label,
|
||||
'langcode' => 'fr',
|
||||
'translation' => 'untranslated',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
|
||||
|
||||
$textarea = current($this->xpath('//textarea'));
|
||||
$lid = (string) $textarea[0]['name'];
|
||||
$edit = array(
|
||||
$edit = [
|
||||
$lid => $fr_site_name_label,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations'));
|
||||
|
||||
// Ensure that the label is in French (and not in English).
|
||||
|
@ -234,10 +234,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalGet($translation_base_url);
|
||||
|
||||
// Case 1: Update new value for site slogan and site name.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][system.site][name]' => 'FR ' . $site_name,
|
||||
'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
|
||||
);
|
||||
];
|
||||
// First time, no overrides, so just Add link.
|
||||
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
|
||||
|
||||
|
@ -245,10 +245,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
|
||||
|
||||
// Expect both name and slogan in language specific file.
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'name' => 'FR ' . $site_name,
|
||||
'slogan' => 'FR ' . $site_slogan,
|
||||
);
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
|
||||
// Case 2: Update new value for site slogan and default value for site name.
|
||||
|
@ -257,12 +257,12 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
// translation form into the actual site name and slogan.
|
||||
$this->assertNoText('FR ' . $site_name);
|
||||
$this->assertNoText('FR ' . $site_slogan);
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][system.site][name]' => $site_name,
|
||||
'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save translation'));
|
||||
$this->assertRaw(t('Successfully updated @language translation.', array('@language' => 'French')));
|
||||
$this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French']));
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
|
||||
|
||||
// Expect only slogan in language specific file.
|
||||
|
@ -272,10 +272,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
// Case 3: Keep default value for site name and slogan.
|
||||
$this->drupalGet("$translation_base_url/fr/edit");
|
||||
$this->assertNoText('FR ' . $site_slogan);
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][system.site][name]' => $site_name,
|
||||
'translation[config_names][system.site][slogan]' => $site_slogan,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Save translation'));
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site');
|
||||
|
||||
|
@ -310,11 +310,11 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
// Save default language configuration.
|
||||
$label = 'Send your feedback';
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'label' => $label,
|
||||
'recipients' => 'sales@example.com,support@example.com',
|
||||
'reply' => 'Thank you for your mail',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/contact/manage/feedback', $edit, t('Save'));
|
||||
|
||||
// Ensure translation link is present.
|
||||
|
@ -323,7 +323,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
// Make sure translate tab is present.
|
||||
$this->drupalGet('admin/structure/contact/manage/feedback');
|
||||
$this->assertLink(t('Translate @type', array('@type' => 'contact form')));
|
||||
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
|
||||
|
||||
// Visit the form to confirm the changes.
|
||||
$this->drupalGet('contact/feedback');
|
||||
|
@ -331,7 +331,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$this->drupalGet($translation_base_url);
|
||||
$this->assertLink(t('Translate @type', array('@type' => 'contact form')));
|
||||
$this->assertLink(t('Translate @type', ['@type' => 'contact form']));
|
||||
|
||||
// 'Add' link should be present for $langcode translation.
|
||||
$translation_page_url = "$translation_base_url/$langcode/add";
|
||||
|
@ -342,20 +342,20 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertText($label);
|
||||
|
||||
// Update translatable fields.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][contact.form.feedback][label]' => 'Website feedback - ' . $langcode,
|
||||
'translation[config_names][contact.form.feedback][reply]' => 'Thank you for your mail - ' . $langcode,
|
||||
);
|
||||
];
|
||||
|
||||
// Save language specific version of form.
|
||||
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
|
||||
|
||||
// Expect translated values in language specific file.
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback');
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'label' => 'Website feedback - ' . $langcode,
|
||||
'reply' => 'Thank you for your mail - ' . $langcode,
|
||||
);
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
|
||||
// Check for edit, delete links (and no 'add' link) for $langcode.
|
||||
|
@ -368,10 +368,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertText('Website feedback - ' . $langcode);
|
||||
|
||||
// Submit feedback.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'subject[0][value]' => 'Test subject',
|
||||
'message[0][value]' => 'Test message',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Send message'));
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
// original text all appear in any translated page on the translation
|
||||
// forms.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$langcode_prefixes = array_merge(array(''), $this->langcodes);
|
||||
$langcode_prefixes = array_merge([''], $this->langcodes);
|
||||
foreach ($langcode_prefixes as $langcode_prefix) {
|
||||
$this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit", '/'));
|
||||
$this->assertFieldByName('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode);
|
||||
|
@ -400,14 +400,14 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
// Test that delete links work and operations perform properly.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$replacements = array('%label' => t('@label @entity_type', array('@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName());
|
||||
$replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()];
|
||||
|
||||
$this->drupalGet("$translation_base_url/$langcode/delete");
|
||||
$this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements));
|
||||
// Assert link back to list page to cancel delete is present.
|
||||
$this->assertLinkByHref($translation_base_url);
|
||||
|
||||
$this->drupalPostForm(NULL, array(), t('Delete'));
|
||||
$this->drupalPostForm(NULL, [], t('Delete'));
|
||||
$this->assertRaw(t('@language translation of %label was deleted', $replacements));
|
||||
$this->assertLinkByHref("$translation_base_url/$langcode/add");
|
||||
$this->assertNoLinkByHref("translation_base_url/$langcode/edit");
|
||||
|
@ -445,18 +445,18 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium');
|
||||
|
||||
// Save default language configuration for a new format.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'label' => 'Custom medium date',
|
||||
'id' => 'custom_medium',
|
||||
'date_format_pattern' => 'Y. m. d. H:i',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format'));
|
||||
|
||||
// Test translating a default shipped format and our custom format.
|
||||
$formats = array(
|
||||
$formats = [
|
||||
'medium' => 'Default medium date',
|
||||
'custom_medium' => 'Custom medium date',
|
||||
);
|
||||
];
|
||||
foreach ($formats as $id => $label) {
|
||||
$translation_base_url = 'admin/config/regional/date-time/formats/manage/' . $id . '/translate';
|
||||
|
||||
|
@ -474,20 +474,20 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertRaw('core/modules/system/js/system.date.js');
|
||||
|
||||
// Update translatable fields.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][core.date_format.' . $id . '][label]' => $id . ' - FR',
|
||||
'translation[config_names][core.date_format.' . $id . '][pattern]' => 'D',
|
||||
);
|
||||
];
|
||||
|
||||
// Save language specific version of form.
|
||||
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
|
||||
|
||||
// Get translation and check we've got the right value.
|
||||
$override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'core.date_format.' . $id);
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'label' => $id . ' - FR',
|
||||
'pattern' => 'D',
|
||||
);
|
||||
];
|
||||
$this->assertEqual($expected, $override->get());
|
||||
|
||||
// Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should
|
||||
|
@ -508,18 +508,18 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/config/people/accounts');
|
||||
$this->assertLink(t('Translate @type', array('@type' => 'account settings')));
|
||||
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
|
||||
|
||||
$this->drupalGet('admin/config/people/accounts/translate');
|
||||
$this->assertLink(t('Translate @type', array('@type' => 'account settings')));
|
||||
$this->assertLink(t('Translate @type', ['@type' => 'account settings']));
|
||||
$this->assertLinkByHref('admin/config/people/accounts/translate/fr/add');
|
||||
|
||||
// Update account settings fields for French.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
|
||||
'translation[config_names][user.mail][status_blocked][subject]' => 'Testing, your account is blocked.',
|
||||
'translation[config_names][user.mail][status_blocked][body]' => 'Testing account blocked body.',
|
||||
);
|
||||
];
|
||||
|
||||
$this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation'));
|
||||
|
||||
|
@ -588,7 +588,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Assert contextual link related to views.
|
||||
$ids = array('entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1');
|
||||
$ids = ['entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1'];
|
||||
$response = $this->renderContextualLinks($ids, 'node');
|
||||
$this->assertResponse(200);
|
||||
$json = Json::decode($response);
|
||||
|
@ -611,14 +611,14 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertRaw($human_readable_name);
|
||||
|
||||
// Update Views Fields for French.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][views.view.frontpage][description]' => $description . " FR",
|
||||
'translation[config_names][views.view.frontpage][label]' => $human_readable_name . " FR",
|
||||
'translation[config_names][views.view.frontpage][display][default][display_title]' => $display_settings_master . " FR",
|
||||
'translation[config_names][views.view.frontpage][display][default][display_options][title]' => $display_options_master . " FR",
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation'));
|
||||
$this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French')));
|
||||
$this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French']));
|
||||
|
||||
// Check for edit, delete links (and no 'add' link) for French language.
|
||||
$this->assertNoLinkByHref("$translation_base_url/fr/add");
|
||||
|
@ -640,20 +640,20 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Languages to test, with various number of plural forms.
|
||||
$languages = array(
|
||||
'vi' => array('plurals' => 1, 'expected' => array(TRUE, FALSE, FALSE, FALSE)),
|
||||
'fr' => array('plurals' => 2, 'expected' => array(TRUE, TRUE, FALSE, FALSE)),
|
||||
'sl' => array('plurals' => 4, 'expected' => array(TRUE, TRUE, TRUE, TRUE)),
|
||||
);
|
||||
$languages = [
|
||||
'vi' => ['plurals' => 1, 'expected' => [TRUE, FALSE, FALSE, FALSE]],
|
||||
'fr' => ['plurals' => 2, 'expected' => [TRUE, TRUE, FALSE, FALSE]],
|
||||
'sl' => ['plurals' => 4, 'expected' => [TRUE, TRUE, TRUE, TRUE]],
|
||||
];
|
||||
|
||||
foreach ($languages as $langcode => $data) {
|
||||
// Import a .po file to add a new language with a given number of plural forms
|
||||
$name = \Drupal::service('file_system')->tempnam('temporary://', $langcode . '_') . '.po';
|
||||
file_put_contents($name, $this->getPoFile($data['plurals']));
|
||||
$this->drupalPostForm('admin/config/regional/translate/import', array(
|
||||
$this->drupalPostForm('admin/config/regional/translate/import', [
|
||||
'langcode' => $langcode,
|
||||
'files[file]' => $name,
|
||||
), t('Import'));
|
||||
], t('Import'));
|
||||
|
||||
// Change the config langcode of the 'files' view.
|
||||
$config = \Drupal::service('config.factory')->getEditable('views.view.files');
|
||||
|
@ -686,10 +686,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
// This will also automatically add the 'sl' language.
|
||||
$name = \Drupal::service('file_system')->tempnam('temporary://', "sl_") . '.po';
|
||||
file_put_contents($name, $this->getPoFile(4));
|
||||
$this->drupalPostForm('admin/config/regional/translate/import', array(
|
||||
$this->drupalPostForm('admin/config/regional/translate/import', [
|
||||
'langcode' => 'sl',
|
||||
'files[file]' => $name,
|
||||
), t('Import'));
|
||||
], t('Import'));
|
||||
|
||||
// Translate the files view, as this one uses numeric formatters.
|
||||
$description = 'Singular form';
|
||||
|
@ -817,12 +817,12 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
$langcode = 'xx';
|
||||
$name = $this->randomMachineName(16);
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'predefined_langcode' => 'custom',
|
||||
'langcode' => $langcode,
|
||||
'label' => $name,
|
||||
'direction' => Language::DIRECTION_LTR,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language'));
|
||||
|
||||
// Make sure there is no translation stored in locale storage before edit.
|
||||
|
@ -830,9 +830,9 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertTrue(empty($translation));
|
||||
|
||||
// Add custom translation.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][user.settings][anonymous]' => 'Anonyme',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation'));
|
||||
|
||||
// Make sure translation stored in locale storage after saved language
|
||||
|
@ -841,9 +841,9 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertEqual('Anonyme', $translation->getString());
|
||||
|
||||
// revert custom translations to base translation.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][user.settings][anonymous]' => 'Anonymous',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/people/accounts/translate/fr/edit', $edit, t('Save translation'));
|
||||
|
||||
// Make sure there is no translation stored in locale storage after revert.
|
||||
|
@ -858,19 +858,19 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Delete French language
|
||||
$this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete'));
|
||||
$this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'French', '%langcode' => 'fr')));
|
||||
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
|
||||
$this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr']));
|
||||
|
||||
// Change default language to Tamil.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'site_default_language' => 'ta',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
|
||||
$this->assertRaw(t('Configuration saved.'));
|
||||
|
||||
// Delete English language
|
||||
$this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete'));
|
||||
$this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'English', '%langcode' => 'en')));
|
||||
$this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
|
||||
$this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en']));
|
||||
|
||||
// Visit account setting translation page, this should not
|
||||
// throw any notices.
|
||||
|
@ -907,32 +907,32 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
|
||||
$config_factory = $this->container->get('config.factory');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'kitten',
|
||||
'llama',
|
||||
'elephant'
|
||||
);
|
||||
];
|
||||
$actual = $config_factory
|
||||
->getEditable('config_translation_test.content')
|
||||
->get('animals');
|
||||
$this->assertEqual($expected, $actual);
|
||||
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][config_translation_test.content][content][value]' => '<p><strong>Hello World</strong> - FR</p>',
|
||||
'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR',
|
||||
'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR',
|
||||
'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/media/file-system/translate/fr/add', $edit, t('Save translation'));
|
||||
|
||||
$this->container->get('language.config_factory_override')
|
||||
->setLanguage(new Language(array('id' => 'fr')));
|
||||
->setLanguage(new Language(['id' => 'fr']));
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'kitten - FR',
|
||||
'llama - FR',
|
||||
'elephant - FR',
|
||||
);
|
||||
];
|
||||
$actual = $config_factory
|
||||
->get('config_translation_test.content')
|
||||
->get('animals');
|
||||
|
@ -947,10 +947,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
|
||||
$config_factory = $this->container->get('config.factory');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'value' => '<p><strong>Hello World</strong></p>',
|
||||
'format' => 'plain_text',
|
||||
);
|
||||
];
|
||||
$actual = $config_factory
|
||||
->get('config_translation_test.content')
|
||||
->getOriginal('content', FALSE);
|
||||
|
@ -970,20 +970,20 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->assertNoFieldByName('translation[config_names][config_translation_test.content][content][format]');
|
||||
|
||||
// Update translatable fields.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][config_translation_test.content][content][value]' => '<p><strong>Hello World</strong> - FR</p>',
|
||||
);
|
||||
];
|
||||
|
||||
// Save language specific version of form.
|
||||
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
|
||||
|
||||
// Get translation and check we've got the right value.
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'value' => '<p><strong>Hello World</strong> - FR</p>',
|
||||
'format' => 'plain_text',
|
||||
);
|
||||
];
|
||||
$this->container->get('language.config_factory_override')
|
||||
->setLanguage(new Language(array('id' => 'fr')));
|
||||
->setLanguage(new Language(['id' => 'fr']));
|
||||
$actual = $config_factory
|
||||
->get('config_translation_test.content')
|
||||
->get('content');
|
||||
|
@ -1009,7 +1009,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalLogin($this->translatorUser);
|
||||
$this->drupalGet($translation_page_url);
|
||||
$this->assertDisabledTextarea('edit-translation-config-names-config-translation-testcontent-content-value');
|
||||
$this->drupalPostForm(NULL, array(), t('Save translation'));
|
||||
$this->drupalPostForm(NULL, [], t('Save translation'));
|
||||
// Check that submitting the form did not update the text format of the
|
||||
// translation.
|
||||
$actual = $config_factory
|
||||
|
@ -1019,14 +1019,14 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
// The administrator must explicitly change the text format.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'translation[config_names][config_translation_test.content][content][format]' => 'full_html',
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm($translation_page_url, $edit, t('Save translation'));
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'value' => '<p><strong>Hello World</strong> - FR</p>',
|
||||
'format' => 'full_html',
|
||||
);
|
||||
];
|
||||
$actual = $config_factory
|
||||
->get('config_translation_test.content')
|
||||
->get('content');
|
||||
|
@ -1047,20 +1047,20 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
* Returns translation if exists, FALSE otherwise.
|
||||
*/
|
||||
protected function getTranslation($config_name, $key, $langcode) {
|
||||
$settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name));
|
||||
$this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name)));
|
||||
$settings_locations = $this->localeStorage->getLocations(['type' => 'configuration', 'name' => $config_name]);
|
||||
$this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', ['%config_name' => $config_name]));
|
||||
|
||||
if (!empty($settings_locations)) {
|
||||
$source = $this->container->get('config.factory')->get($config_name)->get($key);
|
||||
$source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration'));
|
||||
$this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key)));
|
||||
$source_string = $this->localeStorage->findString(['source' => $source, 'type' => 'configuration']);
|
||||
$this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', ['%config_name' => $config_name, '%key' => $key]));
|
||||
|
||||
if (!empty($source_string)) {
|
||||
$conditions = array(
|
||||
$conditions = [
|
||||
'lid' => $source_string->lid,
|
||||
'language' => $langcode,
|
||||
);
|
||||
$translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE));
|
||||
];
|
||||
$translations = $this->localeStorage->getTranslations($conditions + ['translated' => TRUE]);
|
||||
return reset($translations);
|
||||
}
|
||||
}
|
||||
|
@ -1074,10 +1074,10 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
* @param string $site_slogan
|
||||
*/
|
||||
protected function setSiteInformation($site_name, $site_slogan) {
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'site_name' => $site_name,
|
||||
'site_slogan' => $site_slogan,
|
||||
);
|
||||
];
|
||||
$this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
|
||||
$this->assertRaw(t('The configuration options have been saved.'));
|
||||
}
|
||||
|
@ -1094,11 +1094,11 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
* The response body.
|
||||
*/
|
||||
protected function renderContextualLinks($ids, $current_path) {
|
||||
$post = array();
|
||||
$post = [];
|
||||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$post['ids[' . $i . ']'] = $ids[$i];
|
||||
}
|
||||
return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path)));
|
||||
return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1111,30 +1111,30 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
* TRUE if the assertion passed; FALSE otherwise.
|
||||
*/
|
||||
protected function assertDisabledTextarea($id) {
|
||||
$textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', array(
|
||||
$textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [
|
||||
':id' => $id,
|
||||
));
|
||||
]);
|
||||
$textarea = reset($textarea);
|
||||
$passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array(
|
||||
$passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [
|
||||
'@id' => $id,
|
||||
)));
|
||||
]));
|
||||
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
|
||||
$passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array(
|
||||
$passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [
|
||||
'@id' => $id,
|
||||
)));
|
||||
]));
|
||||
// Make sure the text format select is not shown.
|
||||
$select_id = str_replace('value', 'format--2', $id);
|
||||
$select = $this->xpath('//select[@id=:id]', array(':id' => $select_id));
|
||||
return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array(
|
||||
$select = $this->xpath('//select[@id=:id]', [':id' => $select_id]);
|
||||
return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [
|
||||
'@id' => $id,
|
||||
)));
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that returns a .po file with a given number of plural forms.
|
||||
*/
|
||||
public function getPoFile($plurals) {
|
||||
$po_file = array();
|
||||
$po_file = [];
|
||||
|
||||
$po_file[1] = <<< EOF
|
||||
msgid ""
|
||||
|
|
|
@ -24,7 +24,7 @@ class ConfigTranslationUiThemeTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = array('fr', 'ta');
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
|
||||
use Drupal\views_ui\Tests\UITestBase;
|
||||
|
||||
/**
|
||||
* Visit view list and test if translate is available.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationViewListUiTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('node', 'test_view');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('config_translation', 'views_ui');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$permissions = array(
|
||||
'administer views',
|
||||
'translate configuration',
|
||||
);
|
||||
|
||||
// Create and log in user.
|
||||
$this->drupalLogin($this->drupalCreateUser($permissions));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests views_ui list to see if translate link is added to operations.
|
||||
*/
|
||||
public function testTranslateOperationInViewListUi() {
|
||||
// Views UI List 'admin/structure/views'.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$translate_link = 'admin/structure/views/view/test_view/translate';
|
||||
// Test if the link to translate the test_view is on the page.
|
||||
$this->assertLinkByHref($translate_link);
|
||||
|
||||
// Test if the link to translate actually goes to the translate page.
|
||||
$this->drupalGet($translate_link);
|
||||
$this->assertRaw('<th>' . t('Language') . '</th>');
|
||||
|
||||
// Test that the 'Edit' tab appears.
|
||||
$this->assertLinkByHref('admin/structure/views/view/test_view');
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue