updated core to 8.6.1 via composer
This commit is contained in:
@@ -6,4 +6,4 @@ version: VERSION
|
||||
core: 8.x
|
||||
configure: config_translation.mapper_list
|
||||
dependencies:
|
||||
- locale
|
||||
- drupal:locale
|
||||
|
||||
@@ -3,6 +3,7 @@ label: Maintenance page configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: variable_translation
|
||||
variables:
|
||||
|
||||
@@ -3,6 +3,7 @@ label: Site configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: variable_translation
|
||||
constants:
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
id: d6_taxonomy_vocabulary_translation
|
||||
label: Taxonomy vocabularies
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_taxonomy_vocabulary_translation
|
||||
process:
|
||||
vid:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: name
|
||||
-
|
||||
plugin: substr
|
||||
length: 32
|
||||
langcode: language
|
||||
property:
|
||||
plugin: static_map
|
||||
source: property
|
||||
map:
|
||||
name: name
|
||||
description: description
|
||||
translation: translation
|
||||
destination:
|
||||
plugin: entity:taxonomy_vocabulary
|
||||
destination_module: config_translation
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_taxonomy_vocabulary
|
||||
@@ -3,6 +3,7 @@ label: User mail configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: variable_translation
|
||||
variables:
|
||||
|
||||
+13
-1
@@ -3,6 +3,7 @@ label: User profile field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_profile_field_translation
|
||||
constants:
|
||||
@@ -12,7 +13,18 @@ process:
|
||||
langcode: language
|
||||
entity_type: 'constants/entity_type'
|
||||
bundle: 'constants/bundle'
|
||||
field_name: name
|
||||
field_name:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: user_profile_field
|
||||
source: fid
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
property:
|
||||
plugin: static_map
|
||||
source: property
|
||||
|
||||
@@ -3,6 +3,7 @@ label: User configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: variable_translation
|
||||
variables:
|
||||
|
||||
@@ -13,6 +13,7 @@ use Drupal\Core\StringTranslation\TranslationInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\locale\LocaleConfigManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
@@ -73,9 +74,11 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
||||
* The entity manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
|
||||
* The event dispatcher.
|
||||
*/
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager);
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) {
|
||||
parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager, $event_dispatcher);
|
||||
$this->setType($plugin_definition['entity_type']);
|
||||
|
||||
$this->entityManager = $entity_manager;
|
||||
@@ -97,7 +100,8 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
||||
$container->get('router.route_provider'),
|
||||
$container->get('string_translation'),
|
||||
$container->get('entity.manager'),
|
||||
$container->get('language_manager')
|
||||
$container->get('language_manager'),
|
||||
$container->get('event_dispatcher')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,9 +109,9 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match) {
|
||||
parent::populateFromRouteMatch($route_match);
|
||||
$entity = $route_match->getParameter($this->entityType);
|
||||
$this->setEntity($entity);
|
||||
parent::populateFromRouteMatch($route_match);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -263,7 +267,7 @@ class ConfigEntityMapper extends ConfigNamesMapper {
|
||||
$parameters += [
|
||||
$this->entityType => [
|
||||
'type' => 'entity:' . $this->entityType,
|
||||
]
|
||||
],
|
||||
];
|
||||
$route->setOption('parameters', $parameters);
|
||||
}
|
||||
|
||||
@@ -282,12 +282,12 @@ interface ConfigMapperInterface {
|
||||
public function hasTranslation(LanguageInterface $language);
|
||||
|
||||
/**
|
||||
* Populate the config mapper with request data.
|
||||
*
|
||||
* @todo Replace $request with RouteMatch https://www.drupal.org/node/2295255.
|
||||
* Populate the config mapper with route match data.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match.
|
||||
*
|
||||
* @see \Drupal\config_translation\Event\ConfigTranslationEvents::POPULATE_MAPPER
|
||||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match);
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Drupal\config_translation;
|
||||
|
||||
use Drupal\config_translation\Event\ConfigMapperPopulateEvent;
|
||||
use Drupal\config_translation\Event\ConfigTranslationEvents;
|
||||
use Drupal\config_translation\Exception\ConfigMapperLanguageException;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Config\TypedConfigManagerInterface;
|
||||
@@ -15,6 +17,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\locale\LocaleConfigManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
@@ -86,6 +89,13 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigNamesMapper.
|
||||
*
|
||||
@@ -115,12 +125,14 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
||||
* The string translation manager.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
|
||||
* (optional) The event dispatcher.
|
||||
*
|
||||
* @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
|
||||
* Throws an exception if the route specified by the 'base_route_name' in
|
||||
* the plugin definition could not be found by the route provider.
|
||||
*/
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager) {
|
||||
public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) {
|
||||
$this->pluginId = $plugin_id;
|
||||
$this->pluginDefinition = $plugin_definition;
|
||||
$this->routeProvider = $route_provider;
|
||||
@@ -132,6 +144,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
||||
|
||||
$this->stringTranslation = $string_translation;
|
||||
$this->languageManager = $language_manager;
|
||||
$this->eventDispatcher = $event_dispatcher ?: \Drupal::service('event_dispatcher');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +162,8 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
||||
$container->get('plugin.manager.config_translation.mapper'),
|
||||
$container->get('router.route_provider'),
|
||||
$container->get('string_translation'),
|
||||
$container->get('language_manager')
|
||||
$container->get('language_manager'),
|
||||
$container->get('event_dispatcher')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -368,6 +382,9 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
||||
*/
|
||||
public function populateFromRouteMatch(RouteMatchInterface $route_match) {
|
||||
$this->langcode = $route_match->getParameter('langcode');
|
||||
|
||||
$event = new ConfigMapperPopulateEvent($this, $route_match);
|
||||
$this->eventDispatcher->dispatch(ConfigTranslationEvents::POPULATE_MAPPER, $event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,7 +139,7 @@ class ConfigTranslationController extends ControllerBase {
|
||||
|
||||
$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>.', [':url' => $this->url('entity.configurable_language.collection')]), 'warning');
|
||||
$this->messenger()->addWarning($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')]));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -162,7 +162,7 @@ class ConfigTranslationController extends ControllerBase {
|
||||
'#items' => $items,
|
||||
],
|
||||
];
|
||||
drupal_set_message($this->renderer->renderPlain($message), 'warning');
|
||||
$this->messenger()->addWarning($this->renderer->renderPlain($message));
|
||||
|
||||
$original_langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED;
|
||||
$operations_access = FALSE;
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\config_translation\Controller;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
@@ -97,7 +96,7 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild
|
||||
public function getFilterLabels() {
|
||||
$info = parent::getFilterLabels();
|
||||
$bundle = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle');
|
||||
$bundle = Unicode::strtolower($bundle);
|
||||
$bundle = mb_strtolower($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]);
|
||||
|
||||
@@ -45,7 +45,8 @@ class ConfigTranslationListController extends ControllerBase {
|
||||
* The name of the mapper.
|
||||
*
|
||||
* @return array
|
||||
* A render array as expected by drupal_render().
|
||||
* A render array as expected by
|
||||
* \Drupal\Core\Render\RendererInterface::render().
|
||||
*
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* Throws an exception if a mapper plugin could not be instantiated from the
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Event;
|
||||
|
||||
use Drupal\config_translation\ConfigMapperInterface;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Provides a class for events related to configuration translation mappers.
|
||||
*/
|
||||
class ConfigMapperPopulateEvent extends Event {
|
||||
|
||||
/**
|
||||
* The configuration mapper this event is related to.
|
||||
*
|
||||
* @var \Drupal\config_translation\ConfigMapperInterface
|
||||
*/
|
||||
protected $mapper;
|
||||
|
||||
/**
|
||||
* The route match this event is related to.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteMatchInterface
|
||||
*/
|
||||
protected $routeMatch;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigMapperPopulateEvent object.
|
||||
*
|
||||
* @param \Drupal\config_translation\ConfigMapperInterface $mapper
|
||||
* The configuration mapper this event is related to.
|
||||
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
|
||||
* The route match this event is related to.
|
||||
*/
|
||||
public function __construct(ConfigMapperInterface $mapper, RouteMatchInterface $route_match) {
|
||||
$this->mapper = $mapper;
|
||||
$this->routeMatch = $route_match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the configuration mapper this event is related to.
|
||||
*
|
||||
* @return \Drupal\config_translation\ConfigMapperInterface
|
||||
* The configuration mapper this event is related to.
|
||||
*/
|
||||
public function getMapper() {
|
||||
return $this->mapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the route match this event is related to.
|
||||
*
|
||||
* @return \Drupal\Core\Routing\RouteMatchInterface
|
||||
* The route match this event is related to.
|
||||
*/
|
||||
public function getRouteMatch() {
|
||||
return $this->routeMatch;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Event;
|
||||
|
||||
/**
|
||||
* Provides a list of events dispatched by the Configuration Translation module.
|
||||
*/
|
||||
final class ConfigTranslationEvents {
|
||||
|
||||
/**
|
||||
* The name of the event dispatched when a configuration mapper is populated.
|
||||
*
|
||||
* Allows modules to add related config for translation on a specific
|
||||
* translation form.
|
||||
*
|
||||
* @see \Drupal\config_translation\ConfigMapperInterface::populateFromRouteMatch()
|
||||
*/
|
||||
const POPULATE_MAPPER = 'config_translation.populate_mapper';
|
||||
|
||||
}
|
||||
@@ -36,7 +36,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.', ['@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
||||
$cache_backend->deleteAll();
|
||||
}
|
||||
|
||||
drupal_set_message($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));
|
||||
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,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.', ['@language' => $this->language->getName()]));
|
||||
$this->messenger()->addStatus($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\config_translation\FormElement;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\language\Config\LanguageConfigOverride;
|
||||
@@ -20,7 +20,7 @@ class PluralVariants extends FormElementBase {
|
||||
$values = explode(LOCALE_PLURAL_DELIMITER, $source_config);
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@source_language)</span>', [
|
||||
'#title' => new FormattableMarkup('@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(),
|
||||
@@ -32,7 +32,7 @@ class PluralVariants extends FormElementBase {
|
||||
'#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>', [
|
||||
'#markup' => new FormattableMarkup('<span lang="@langcode">@value</span>', [
|
||||
'@langcode' => $source_language->getId(),
|
||||
'@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'),
|
||||
]),
|
||||
@@ -49,7 +49,7 @@ class PluralVariants extends FormElementBase {
|
||||
$values = explode(LOCALE_PLURAL_DELIMITER, $translation_config);
|
||||
$element = [
|
||||
'#type' => 'fieldset',
|
||||
'#title' => SafeMarkup::format('@label <span class="visually-hidden">(@translation_language)</span>', [
|
||||
'#title' => new FormattableMarkup('@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(),
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\config_translation\Plugin\Menu\ContextualLink;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Menu\ContextualLinkDefault;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -28,7 +27,7 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
|
||||
// retrieve the title. We need to retrieve a runtime title (as opposed to
|
||||
// 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());
|
||||
$type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Drupal\config_translation\Plugin\Menu\LocalTask;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Menu\LocalTaskDefault;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -28,7 +27,7 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
|
||||
// retrieve title. We need to retrieve a runtime title (as opposed to
|
||||
// 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());
|
||||
$type_name = mb_strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel());
|
||||
return $this->t('Translate @type_name', ['@type_name' => $type_name]);
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -18,4 +18,3 @@ config_translation_test.content:
|
||||
label: 'Animals'
|
||||
sequence:
|
||||
type: label
|
||||
|
||||
|
||||
+2
-2
@@ -5,5 +5,5 @@ package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_translation
|
||||
- config_test
|
||||
- drupal:config_translation
|
||||
- drupal:config_test
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
services:
|
||||
config_translation_test_event_subscriber:
|
||||
class: Drupal\config_translation_test\EventSubscriber\ConfigTranslationTestSubscriber
|
||||
tags:
|
||||
- {name: event_subscriber}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_translation_test\EventSubscriber;
|
||||
|
||||
use Drupal\config_translation\Event\ConfigMapperPopulateEvent;
|
||||
use Drupal\config_translation\Event\ConfigTranslationEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Adds configuration names to configuration mapper on POPULATE_MAPPER event.
|
||||
*/
|
||||
class ConfigTranslationTestSubscriber implements EventSubscriberInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
return [
|
||||
ConfigTranslationEvents::POPULATE_MAPPER => [
|
||||
['addConfigNames'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reacts to the populating of a configuration mapper.
|
||||
*
|
||||
* @param \Drupal\config_translation\Event\ConfigMapperPopulateEvent $event
|
||||
* The configuration mapper event.
|
||||
*/
|
||||
public function addConfigNames(ConfigMapperPopulateEvent $event) {
|
||||
$mapper = $event->getMapper();
|
||||
if ($mapper->getBaseRouteName() === 'system.site_information_settings' && $mapper->getLangcode() === 'en') {
|
||||
$mapper->addConfigName('config_translation_test.content');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@ class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
'system'
|
||||
'system',
|
||||
];
|
||||
|
||||
protected function setUp() {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\simpletest\InstallerTestBase;
|
||||
use Drupal\FunctionalTests\Installer\InstallerTestBase;
|
||||
|
||||
/**
|
||||
* Installs the config translation module on a site installed in non english.
|
||||
+13
-13
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
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;
|
||||
@@ -80,6 +79,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
|
||||
->save();
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
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));
|
||||
$id = mb_strtolower($this->randomMachineName(16));
|
||||
$this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]);
|
||||
|
||||
// Get the Block listing.
|
||||
@@ -116,7 +116,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// this does not test more than necessary.
|
||||
$this->drupalGet('admin/structure/menu/add');
|
||||
// Lowercase the machine name.
|
||||
$menu_name = Unicode::strtolower($this->randomMachineName(16));
|
||||
$menu_name = mb_strtolower($this->randomMachineName(16));
|
||||
$label = $this->randomMachineName(16);
|
||||
$edit = [
|
||||
'id' => $menu_name,
|
||||
@@ -164,7 +164,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
$vocabulary = Vocabulary::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'description' => $this->randomMachineName(),
|
||||
'vid' => Unicode::strtolower($this->randomMachineName()),
|
||||
'vid' => mb_strtolower($this->randomMachineName()),
|
||||
]);
|
||||
$vocabulary->save();
|
||||
|
||||
@@ -187,9 +187,9 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// 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([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
'revision' => FALSE
|
||||
'revision' => FALSE,
|
||||
]);
|
||||
$block_content_type->save();
|
||||
|
||||
@@ -212,7 +212,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// 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)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomMachineName(),
|
||||
]);
|
||||
$contact_form->save();
|
||||
@@ -236,7 +236,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// Create a test content type to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$content_type = $this->drupalCreateContentType([
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'type' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
||||
@@ -259,7 +259,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// Create a test format to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$filter_format = FilterFormat::create([
|
||||
'format' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'format' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
$filter_format->save();
|
||||
@@ -283,7 +283,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
// Create a test shortcut to decouple looking for translate operations
|
||||
// link so this does not test more than necessary.
|
||||
$shortcut = ShortcutSet::create([
|
||||
'id' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'id' => mb_strtolower($this->randomMachineName(16)),
|
||||
'label' => $this->randomString(),
|
||||
]);
|
||||
$shortcut->save();
|
||||
@@ -306,7 +306,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
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));
|
||||
$role_id = mb_strtolower($this->randomMachineName(16));
|
||||
$this->drupalCreateRole([], $role_id);
|
||||
|
||||
// Get the role listing.
|
||||
@@ -387,7 +387,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
public function doFieldListTest() {
|
||||
// Create a base content type.
|
||||
$content_type = $this->drupalCreateContentType([
|
||||
'type' => Unicode::strtolower($this->randomMachineName(16)),
|
||||
'type' => mb_strtolower($this->randomMachineName(16)),
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
||||
@@ -395,7 +395,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase {
|
||||
$block_content_type = BlockContentType::create([
|
||||
'id' => 'basic',
|
||||
'label' => 'Basic',
|
||||
'revision' => FALSE
|
||||
'revision' => FALSE,
|
||||
]);
|
||||
$block_content_type->save();
|
||||
$field = FieldConfig::create([
|
||||
|
||||
@@ -4,8 +4,7 @@ namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\Test\AssertMailTrait;
|
||||
@@ -404,7 +403,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
||||
|
||||
// Test that delete links work and operations perform properly.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$replacements = ['%label' => t('@label @entity_type', ['@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' => mb_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));
|
||||
@@ -808,6 +807,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
||||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
|
||||
->save();
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
@@ -907,7 +907,7 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
||||
$expected = [
|
||||
'kitten',
|
||||
'llama',
|
||||
'elephant'
|
||||
'elephant',
|
||||
];
|
||||
$actual = $config_factory
|
||||
->getEditable('config_translation_test.content')
|
||||
@@ -1151,17 +1151,17 @@ class ConfigTranslationUiTest extends BrowserTestBase {
|
||||
':id' => $id,
|
||||
]);
|
||||
$textarea = reset($textarea);
|
||||
$this->assertTrue($textarea instanceof NodeElement, SafeMarkup::format('Disabled field @id exists.', [
|
||||
$this->assertTrue($textarea instanceof NodeElement, new FormattableMarkup('Disabled field @id exists.', [
|
||||
'@id' => $id,
|
||||
]));
|
||||
$expected = 'This field has been disabled because you do not have sufficient permissions to edit it.';
|
||||
$this->assertEqual($textarea->getText(), $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [
|
||||
$this->assertEqual($textarea->getText(), $expected, new FormattableMarkup('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]', [':id' => $select_id]);
|
||||
return $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [
|
||||
return $this->assertFalse($select, new FormattableMarkup('Field @id does not exist.', [
|
||||
'@id' => $id,
|
||||
]));
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace Drupal\Tests\config_translation\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiTest extends JavascriptTestBase {
|
||||
class ConfigTranslationUiTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel;
|
||||
|
||||
use Drupal\Core\Routing\RouteMatch;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Tests config mapper.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigMapperTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'language',
|
||||
'locale',
|
||||
'system',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests adding config names to mapper.
|
||||
*/
|
||||
public function testAddingConfigNames() {
|
||||
// Get a config names mapper.
|
||||
$mappers = \Drupal::service('plugin.manager.config_translation.mapper')->getMappers();
|
||||
$mapper = $mappers['system.site_information_settings'];
|
||||
|
||||
// Test that it doesn't contain a config name from config_translation_test.
|
||||
$config_names = $mapper->getConfigNames();
|
||||
$this->assertNotContains('config_translation_test.content', $config_names);
|
||||
|
||||
// Call populateFromRouteMatch() to dispatch the "config mapper populate"
|
||||
// event.
|
||||
$mapper->populateFromRouteMatch(new RouteMatch('test', new Route('/')));
|
||||
|
||||
// Test that it contains the new config name from config_translation_test.
|
||||
$config_names = $mapper->getConfigNames();
|
||||
$this->assertContains('config_translation_test.content', $config_names);
|
||||
}
|
||||
|
||||
}
|
||||
+6
-1
@@ -12,7 +12,12 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
*/
|
||||
class MigrateSystemMaintenanceTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['language', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
+6
-1
@@ -12,7 +12,12 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
*/
|
||||
class MigrateSystemSiteTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
public static $modules = ['language', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
+7
-1
@@ -15,7 +15,13 @@ class MigrateUserConfigsTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
public static $modules = ['language', 'locale', 'config_translation'];
|
||||
public static $modules = [
|
||||
'language',
|
||||
'locale',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
||||
+9
-2
@@ -15,7 +15,14 @@ class MigrateUserProfileFieldInstanceTranslationTest extends MigrateDrupal6TestB
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_translation', 'locale', 'language', 'field'];
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'locale',
|
||||
'language',
|
||||
'field',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests migration of translated user profile fields.
|
||||
@@ -28,7 +35,7 @@ class MigrateUserProfileFieldInstanceTranslationTest extends MigrateDrupal6TestB
|
||||
]);
|
||||
$language_manager = $this->container->get('language_manager');
|
||||
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_love_migrations');
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_really_really_love_mig');
|
||||
$this->assertSame("J'aime les migrations", $config_translation->get('label'));
|
||||
$this->assertSame("Si vous cochez cette case, vous aimez les migrations.", $config_translation->get('description'));
|
||||
|
||||
|
||||
+2
-2
@@ -42,8 +42,8 @@ class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
|
||||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation'
|
||||
]
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
|
||||
+2
-2
@@ -41,8 +41,8 @@ class ProfileFieldTranslationTest extends MigrateSqlSourceTestBase {
|
||||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation'
|
||||
]
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
|
||||
@@ -49,6 +49,13 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
protected function setUp() {
|
||||
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
|
||||
@@ -79,6 +86,8 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
||||
|
||||
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configEntityMapper = new ConfigEntityMapper(
|
||||
'configurable_language',
|
||||
$definition,
|
||||
@@ -89,7 +98,8 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
||||
$this->routeProvider,
|
||||
$this->getStringTranslationStub(),
|
||||
$this->entityManager,
|
||||
$this->languageManager
|
||||
$this->languageManager,
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,13 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -54,6 +61,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configFieldMapper = new ConfigFieldMapper(
|
||||
'node_fields',
|
||||
$definition,
|
||||
@@ -64,7 +73,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
||||
$this->getMock('Drupal\Core\Routing\RouteProviderInterface'),
|
||||
$this->getStringTranslationStub(),
|
||||
$this->entityManager,
|
||||
$this->getMock('Drupal\Core\Language\LanguageManagerInterface')
|
||||
$this->getMock('Drupal\Core\Language\LanguageManagerInterface'),
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
||||
$this->getElement(['iii' => 'jjj']),
|
||||
]),
|
||||
]),
|
||||
FALSE
|
||||
FALSE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
|
||||
@@ -88,6 +88,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
/**
|
||||
* The mocked event dispatcher.
|
||||
*
|
||||
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $eventDispatcher;
|
||||
|
||||
protected function setUp() {
|
||||
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
|
||||
|
||||
@@ -122,6 +129,8 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
||||
|
||||
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
|
||||
|
||||
$this->configNamesMapper = new TestConfigNamesMapper(
|
||||
'system.site_information_settings',
|
||||
$this->pluginDefinition,
|
||||
@@ -131,7 +140,8 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
||||
$this->configMapperManager,
|
||||
$this->routeProvider,
|
||||
$this->getStringTranslationStub(),
|
||||
$this->languageManager
|
||||
$this->languageManager,
|
||||
$this->eventDispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user