Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -6,4 +6,4 @@ version: VERSION
|
|||
core: 8.x
|
||||
configure: config_translation.mapper_list
|
||||
dependencies:
|
||||
- locale
|
||||
- drupal:locale
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
id: d6_field_instance_label_description_translation
|
||||
label: Field label and description translation
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_field_instance_label_description_translation
|
||||
constants:
|
||||
entity_type: node
|
||||
process:
|
||||
langcode:
|
||||
plugin: skip_on_empty
|
||||
source: language
|
||||
method: row
|
||||
translation:
|
||||
plugin: skip_on_empty
|
||||
source: translation
|
||||
method: row
|
||||
field_name_parts:
|
||||
plugin: explode
|
||||
source: objectid
|
||||
delimiter: '-'
|
||||
field_name:
|
||||
plugin: extract
|
||||
source: '@field_name_parts'
|
||||
index:
|
||||
- 1
|
||||
bundle:
|
||||
plugin: extract
|
||||
source: '@field_name_parts'
|
||||
index:
|
||||
- 0
|
||||
exists:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_field_instance
|
||||
source:
|
||||
- '@field_name'
|
||||
- '@bundle'
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
entity_type: 'constants/entity_type'
|
||||
property:
|
||||
plugin: static_map
|
||||
source: property
|
||||
bypass: true
|
||||
map:
|
||||
widget_label: label
|
||||
widget_description: description
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
translations: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_field_instance
|
|
@ -0,0 +1,178 @@
|
|||
id: d6_field_instance_option_translation
|
||||
label: Field instance option configuration translation
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_field_instance_option_translation
|
||||
skip_count: true
|
||||
constants:
|
||||
entity_type: node
|
||||
property: settings
|
||||
process:
|
||||
# We skip field types that don't exist because they weren't migrated by the
|
||||
# field migration.
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_field
|
||||
source:
|
||||
- objectid
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
# Use the process from d6_field to determine the field type.
|
||||
type:
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
userreference:
|
||||
userreference_select: entity_reference
|
||||
userreference_buttons: entity_reference
|
||||
userreference_autocomplete: entity_reference
|
||||
nodereference:
|
||||
nodereference_select: entity_reference
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
boolean_type:
|
||||
-
|
||||
plugin: static_map
|
||||
source: '@type'
|
||||
map:
|
||||
boolean: boolean
|
||||
default_value: false
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
bundle:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
langcode:
|
||||
plugin: skip_on_empty
|
||||
source: language
|
||||
method: row
|
||||
field_name: objectid
|
||||
entity_type: 'constants/entity_type'
|
||||
results:
|
||||
plugin: d6_field_instance_option_translation
|
||||
source:
|
||||
- '@type'
|
||||
- global_settings
|
||||
translation:
|
||||
-
|
||||
plugin: extract
|
||||
source: '@results'
|
||||
index: [1]
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
property:
|
||||
-
|
||||
plugin: extract
|
||||
source: '@results'
|
||||
index: [0]
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
destination:
|
||||
plugin: entity:field_config
|
||||
translations: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_node_type
|
||||
- d6_field_instance
|
||||
- d6_field_option_translation
|
|
@ -0,0 +1,144 @@
|
|||
id: d6_field_option_translation
|
||||
label: Field option configuration translation
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_field_option_translation
|
||||
skip_count: true
|
||||
constants:
|
||||
entity_type: node
|
||||
allowed_values: settings
|
||||
process:
|
||||
entity_type: 'constants/entity_type'
|
||||
status: active
|
||||
langcode:
|
||||
plugin: skip_on_empty
|
||||
source: language
|
||||
method: row
|
||||
field_name: objectid
|
||||
# Use the process from d6_field to determine the field type.
|
||||
type:
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
userreference:
|
||||
userreference_select: entity_reference
|
||||
userreference_buttons: entity_reference
|
||||
userreference_autocomplete: entity_reference
|
||||
nodereference:
|
||||
nodereference_select: entity_reference
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
results:
|
||||
plugin: d6_field_option_translation
|
||||
source:
|
||||
- '@type'
|
||||
- global_settings
|
||||
translation:
|
||||
-
|
||||
plugin: extract
|
||||
source: '@results'
|
||||
index: [1]
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
property:
|
||||
-
|
||||
plugin: extract
|
||||
source: '@results'
|
||||
index: [0]
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
destination:
|
||||
plugin: entity:field_storage_config
|
||||
translations: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_field
|
|
@ -1,11 +1,14 @@
|
|||
id: d6_i18n_system_maintenance
|
||||
id: d6_system_maintenance_translation
|
||||
label: Maintenance page configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: i18n_variable
|
||||
plugin: d6_variable_translation
|
||||
variables:
|
||||
- site_offline_message
|
||||
source_module: i18n
|
||||
process:
|
||||
langcode: language
|
||||
message: site_offline_message
|
|
@ -1,9 +1,11 @@
|
|||
id: d6_i18n_system_site
|
||||
id: d6_system_site_translation
|
||||
label: Site configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: i18n_variable
|
||||
plugin: d6_variable_translation
|
||||
constants:
|
||||
slash: '/'
|
||||
variables:
|
||||
|
@ -13,6 +15,7 @@ source:
|
|||
- site_frontpage
|
||||
- site_403
|
||||
- site_404
|
||||
source_module: i18n
|
||||
process:
|
||||
langcode: language
|
||||
name: site_name
|
|
@ -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
|
|
@ -1,9 +1,11 @@
|
|||
id: d6_i18n_user_mail
|
||||
id: d6_user_mail_translation
|
||||
label: User mail configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: i18n_variable
|
||||
plugin: d6_variable_translation
|
||||
variables:
|
||||
- user_mail_status_activated_subject
|
||||
- user_mail_status_activated_body
|
||||
|
@ -19,6 +21,7 @@ source:
|
|||
- user_mail_register_pending_approval_body
|
||||
- user_mail_status_blocked_subject
|
||||
- user_mail_status_blocked_body
|
||||
source_module: i18n
|
||||
process:
|
||||
langcode: language
|
||||
'status_activated/subject':
|
|
@ -1,9 +1,11 @@
|
|||
id: d6_i18n_user_profile_field_instance
|
||||
id: d6_user_profile_field_instance_translation
|
||||
label: User profile field instance configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d6_i18n_profile_field
|
||||
plugin: d6_profile_field_translation
|
||||
constants:
|
||||
entity_type: user
|
||||
bundle: user
|
||||
|
@ -11,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
|
|
@ -1,15 +1,18 @@
|
|||
id: d6_i18n_user_settings
|
||||
id: d6_user_settings_translation
|
||||
label: User configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: i18n_variable
|
||||
plugin: d6_variable_translation
|
||||
variables:
|
||||
- user_mail_status_blocked_notify
|
||||
- user_mail_status_activated_notify
|
||||
- user_email_verification
|
||||
- user_register
|
||||
- anonymous
|
||||
source_module: i18n
|
||||
process:
|
||||
langcode: language
|
||||
'notify/status_blocked': user_mail_status_blocked_notify
|
|
@ -0,0 +1,17 @@
|
|||
id: d7_system_maintenance_translation
|
||||
label: Maintenance page configuration
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d7_variable_translation
|
||||
variables:
|
||||
- maintenance_mode_message
|
||||
process:
|
||||
langcode: language
|
||||
message: maintenance_mode_message
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.maintenance
|
||||
translations: true
|
|
@ -0,0 +1,27 @@
|
|||
id: d7_system_site_translation
|
||||
label: Site configuration translation
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d7_variable_translation
|
||||
variables:
|
||||
- site_name
|
||||
- site_mail
|
||||
- site_slogan
|
||||
- site_frontpage
|
||||
- site_403
|
||||
- site_404
|
||||
process:
|
||||
langcode: language
|
||||
name: site_name
|
||||
mail: site_mail
|
||||
slogan: site_slogan
|
||||
'page/front': site_frontpage
|
||||
'page/403': site_403
|
||||
'page/404': site_404
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: system.site
|
||||
translations: true
|
|
@ -0,0 +1,79 @@
|
|||
id: d7_user_mail_translation
|
||||
label: User mail configuration translation
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d7_variable_translation
|
||||
variables:
|
||||
- user_mail_cancel_confirm_subject
|
||||
- user_mail_cancel_confirm_body
|
||||
- user_mail_password_reset_subject
|
||||
- user_mail_password_reset_body
|
||||
- user_mail_register_admin_created_subject
|
||||
- user_mail_register_admin_created_body
|
||||
- user_mail_register_no_approval_required_subject
|
||||
- user_mail_register_no_approval_required_body
|
||||
- user_mail_register_pending_approval_subject
|
||||
- user_mail_register_pending_approval_body
|
||||
- user_mail_status_activated_subject
|
||||
- user_mail_status_activated_body
|
||||
- user_mail_status_blocked_subject
|
||||
- user_mail_status_blocked_body
|
||||
- user_mail_status_canceled_subject
|
||||
- user_mail_status_canceled_body
|
||||
process:
|
||||
langcode: language
|
||||
'cancel_confirm/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_cancel_confirm_subject
|
||||
'cancel_confirm/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_cancel_confirm_body
|
||||
'password_reset/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_password_reset_subject
|
||||
'password_reset/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_password_reset_body
|
||||
'register_admin_created/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_admin_created_subject
|
||||
'register_admin_created/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_admin_created_body
|
||||
'register_no_approval_required/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_no_approval_required_subject
|
||||
'register_no_approval_required/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_no_approval_required_body
|
||||
'register_pending_approval/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_pending_approval_subject
|
||||
'register_pending_approval/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_register_pending_approval_body
|
||||
'status_activated/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_activated_subject
|
||||
'status_activated/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_activated_body
|
||||
'status_blocked/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_blocked_subject
|
||||
'status_blocked/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_blocked_body
|
||||
'status_canceled/subject':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_canceled_subject
|
||||
'status_canceled/body':
|
||||
plugin: convert_tokens
|
||||
source: user_mail_status_canceled_body
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: user.mail
|
||||
translations: true
|
|
@ -0,0 +1,17 @@
|
|||
id: d7_user_settings_translation
|
||||
label: User settings configuration translation
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
- Configuration
|
||||
- Multilingual
|
||||
source:
|
||||
plugin: d7_variable_translation
|
||||
variables:
|
||||
- anonymous
|
||||
process:
|
||||
langcode: language
|
||||
anonymous: anonymous
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: user.settings
|
||||
translations: true
|
|
@ -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;
|
||||
|
||||
|
@ -61,7 +64,7 @@ class ConfigNamesMapper extends PluginBase implements ConfigMapperInterface, Con
|
|||
/**
|
||||
* The base route object that the mapper is attached to.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route
|
||||
* @var \Symfony\Component\Routing\Route
|
||||
*/
|
||||
protected $baseRoute;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ class ConfigTranslationController extends ControllerBase {
|
|||
/**
|
||||
* The language manager.
|
||||
*
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface
|
||||
*/
|
||||
protected $languageManager;
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
|||
|
||||
/**
|
||||
* Defines a form for adding configuration translations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationAddForm extends ConfigTranslationFormBase {
|
||||
|
||||
|
@ -34,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()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
|
||||
/**
|
||||
* Builds a form to delete configuration translation.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationDeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
@ -140,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());
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Routing\RouteMatchInterface;
|
|||
|
||||
/**
|
||||
* Defines a form for editing configuration translations.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigTranslationEditForm extends ConfigTranslationFormBase {
|
||||
|
||||
|
@ -34,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()]));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ interface ElementInterface {
|
|||
public static function create(TypedDataInterface $schema);
|
||||
|
||||
/**
|
||||
* Builds a render array containg the source and translation form elements.
|
||||
* Builds a render array containing the source and translation form elements.
|
||||
*
|
||||
* @param \Drupal\Core\Language\LanguageInterface $source_language
|
||||
* The source language of the configuration object.
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -15,7 +15,7 @@ class Textarea extends FormElementBase {
|
|||
public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) {
|
||||
// Estimate a comfortable size of the input textarea.
|
||||
$rows_words = ceil(str_word_count($translation_config) / 5);
|
||||
$rows_newlines = substr_count($translation_config, "\n" ) + 1;
|
||||
$rows_newlines = substr_count($translation_config, "\n") + 1;
|
||||
$rows = max($rows_words, $rows_newlines);
|
||||
|
||||
return [
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Defines a contextual link plugin with a dynamic title.
|
||||
|
@ -22,12 +22,12 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle(Request $request = NULL) {
|
||||
// Use the custom 'config_translation_plugin_id' plugin definition key to
|
||||
// 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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Defines a local task plugin with a dynamic title.
|
||||
|
@ -22,12 +22,12 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
public function getTitle(Request $request = NULL) {
|
||||
// Take custom 'config_translation_plugin_id' plugin definition key to
|
||||
// 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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,52 +2,20 @@
|
|||
|
||||
namespace Drupal\config_translation\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\I18nProfileField is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\ProfileFieldTranslation', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* i18n strings profile field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_i18n_profile_field",
|
||||
* source_provider = "i18n"
|
||||
* source_module = "i18nprofile"
|
||||
* )
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use
|
||||
* \Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation
|
||||
* instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2898649
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
class I18nProfileField extends ProfileFieldTranslation {}
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Gets i18n strings profile field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field_translation",
|
||||
* source_module = "i18nprofile"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldTranslation 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,4 +18,3 @@ config_translation_test.content:
|
|||
label: 'Animals'
|
||||
sequence:
|
||||
type: label
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- config_translation
|
||||
- config_test
|
||||
- drupal:config_translation
|
||||
- drupal:config_test
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
services:
|
||||
config_translation_test_event_subscriber:
|
||||
class: Drupal\config_translation_test\EventSubscriber\ConfigTranslationTestSubscriber
|
||||
tags:
|
||||
- {name: event_subscriber}
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationCacheTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = [
|
||||
'block',
|
||||
'config_translation',
|
||||
'config_translation_test',
|
||||
'contact',
|
||||
'contact_test',
|
||||
'contextual',
|
||||
'entity_test',
|
||||
'field_test',
|
||||
'field_ui',
|
||||
'filter',
|
||||
'filter_test',
|
||||
'node',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Languages to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $langcodes = ['fr', 'ta'];
|
||||
|
||||
/**
|
||||
* Administrator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
/**
|
||||
* Translator user for tests.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $translatorUser;
|
||||
|
||||
/**
|
||||
* String translation storage object.
|
||||
*
|
||||
* @var \Drupal\locale\StringStorageInterface
|
||||
*/
|
||||
protected $localeStorage;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$translator_permissions = [
|
||||
'translate configuration',
|
||||
];
|
||||
|
||||
/** @var \Drupal\filter\FilterFormatInterface $filter_test_format */
|
||||
$filter_test_format = FilterFormat::load('filter_test');
|
||||
/** @var \Drupal\filter\FilterFormatInterface $filtered_html_format */
|
||||
$filtered_html_format = FilterFormat::load('filtered_html');
|
||||
/** @var \Drupal\filter\FilterFormatInterface $full_html_format */
|
||||
$full_html_format = FilterFormat::load('full_html');
|
||||
|
||||
$admin_permissions = array_merge($translator_permissions, [
|
||||
'administer languages',
|
||||
'administer site configuration',
|
||||
'link to any page',
|
||||
'administer contact forms',
|
||||
'administer filters',
|
||||
$filtered_html_format->getPermissionName(),
|
||||
$full_html_format->getPermissionName(),
|
||||
$filter_test_format->getPermissionName(),
|
||||
'access site-wide contact form',
|
||||
'access contextual links',
|
||||
'administer account settings',
|
||||
'administer themes',
|
||||
'bypass node access',
|
||||
'administer content types',
|
||||
'translate interface',
|
||||
'administer entity_test fields',
|
||||
]);
|
||||
// Create and login user.
|
||||
$this->translatorUser = $this->drupalCreateUser($translator_permissions);
|
||||
$this->adminUser = $this->drupalCreateUser($admin_permissions);
|
||||
|
||||
// Add languages.
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
ConfigurableLanguage::createFromLangcode($langcode)->save();
|
||||
}
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the translation of field and field storage configuration.
|
||||
*/
|
||||
public function testFieldConfigTranslation() {
|
||||
// Add a test field which has a translatable field setting and a
|
||||
// translatable field storage setting.
|
||||
$field_name = strtolower($this->randomMachineName());
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'test_field',
|
||||
]);
|
||||
|
||||
$translatable_storage_setting = $this->randomString();
|
||||
$field_storage->setSetting('translatable_storage_setting', $translatable_storage_setting);
|
||||
$field_storage->save();
|
||||
|
||||
$bundle = strtolower($this->randomMachineName());
|
||||
entity_test_create_bundle($bundle);
|
||||
$field = FieldConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => $bundle,
|
||||
]);
|
||||
|
||||
$translatable_field_setting = $this->randomString();
|
||||
$field->setSetting('translatable_field_setting', $translatable_field_setting);
|
||||
$field->save();
|
||||
|
||||
$this->drupalLogin($this->translatorUser);
|
||||
|
||||
$this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate");
|
||||
$this->clickLink('Add');
|
||||
|
||||
$this->assertText('Translatable field setting');
|
||||
$this->assertEscaped($translatable_field_setting);
|
||||
$this->assertText('Translatable storage setting');
|
||||
$this->assertEscaped($translatable_storage_setting);
|
||||
|
||||
// Add translation for label.
|
||||
$field_label_fr = $this->randomString();
|
||||
$edit = [
|
||||
"translation[config_names][field.field.entity_test.$bundle.$field_name][label]" => $field_label_fr,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, 'Save translation');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Check if the translated label appears.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
$this->assertEscaped($field_label_fr);
|
||||
|
||||
// Clear cache on French version and check for translated label.
|
||||
$this->drupalPostForm('/fr/admin/config/development/performance', [], 'Clear all caches');
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
// Check if the translation is still there.
|
||||
$this->assertEscaped($field_label_fr);
|
||||
|
||||
// Clear cache on default version and check for translated label.
|
||||
$this->drupalPostForm('/admin/config/development/performance', [], 'Clear all caches');
|
||||
$this->drupalGet("/fr/entity_test/structure/$bundle/fields");
|
||||
// Check if the translation is still there.
|
||||
$this->assertEscaped($field_label_fr);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
|
|||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
'system'
|
||||
'system',
|
||||
];
|
||||
|
||||
protected function setUp() {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests for altering configuration translation forms.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationFormTest extends WebTestBase {
|
||||
class ConfigTranslationFormTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -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.
|
|
@ -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([
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationOverviewTest extends WebTestBase {
|
||||
class ConfigTranslationOverviewTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -77,10 +77,8 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
// Make sure there is only a single operation for each dropbutton, either
|
||||
// 'List' or 'Translate'.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, $dropbutton->count());
|
||||
foreach ($dropbutton->li as $link) {
|
||||
$this->assertTrue(((string) $link->a === 'Translate') || ((string) $link->a === 'List'));
|
||||
}
|
||||
$this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
|
||||
$this->assertTrue(($dropbutton->getText() === 'Translate') || ($dropbutton->getText() === 'List'));
|
||||
}
|
||||
|
||||
$labels = [
|
||||
|
@ -89,8 +87,9 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
$this->randomString(),
|
||||
];
|
||||
|
||||
$storage = \Drupal::entityTypeManager()->getStorage('config_test');
|
||||
foreach ($labels as $label) {
|
||||
$test_entity = entity_create('config_test', [
|
||||
$test_entity = $storage->create([
|
||||
'id' => $this->randomMachineName(),
|
||||
'label' => $label,
|
||||
]);
|
||||
|
@ -104,10 +103,8 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
// Make sure there is only a single 'Translate' operation for each
|
||||
// dropbutton.
|
||||
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
|
||||
$this->assertIdentical(1, $dropbutton->count());
|
||||
foreach ($dropbutton->li as $link) {
|
||||
$this->assertIdentical('Translate', (string) $link->a);
|
||||
}
|
||||
$this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
|
||||
$this->assertIdentical('Translate', $dropbutton->getText());
|
||||
}
|
||||
|
||||
$entity_type = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
|
|
@ -1,26 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
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;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\filter\Entity\FilterFormat;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiTest extends WebTestBase {
|
||||
class ConfigTranslationUiTest extends BrowserTestBase {
|
||||
|
||||
use AssertMailTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -198,7 +200,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
|
||||
|
||||
$textarea = current($this->xpath('//textarea'));
|
||||
$lid = (string) $textarea[0]['name'];
|
||||
$lid = $textarea->getAttribute('name');
|
||||
$edit = [
|
||||
$lid => $fr_site_name_label,
|
||||
];
|
||||
|
@ -389,7 +391,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
}
|
||||
|
||||
// We get all emails so no need to check inside the loop.
|
||||
$captured_emails = $this->drupalGetMails();
|
||||
$captured_emails = $this->getMails();
|
||||
|
||||
// Check language specific auto reply text in email body.
|
||||
foreach ($captured_emails as $email) {
|
||||
|
@ -401,7 +403,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
|
||||
// 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));
|
||||
|
@ -588,13 +590,6 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
public function testViewsTranslationUI() {
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Assert contextual link related to views.
|
||||
$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);
|
||||
$this->assertTrue(strpos($json[$ids[0]], 'Translate view'), 'Translate view contextual link added.');
|
||||
|
||||
$description = 'All content promoted to the front page.';
|
||||
$human_readable_name = 'Frontpage';
|
||||
$display_settings_master = 'Master';
|
||||
|
@ -812,6 +807,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
// tests.
|
||||
$this->config('locale.settings')
|
||||
->set('translation.import_enabled', TRUE)
|
||||
->set('translation.use_source', LOCALE_TRANSLATION_USE_SOURCE_LOCAL)
|
||||
->save();
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
@ -911,7 +907,7 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
$expected = [
|
||||
'kitten',
|
||||
'llama',
|
||||
'elephant'
|
||||
'elephant',
|
||||
];
|
||||
$actual = $config_factory
|
||||
->getEditable('config_translation_test.content')
|
||||
|
@ -1155,17 +1151,17 @@ class ConfigTranslationUiTest extends WebTestBase {
|
|||
':id' => $id,
|
||||
]);
|
||||
$textarea = reset($textarea);
|
||||
$passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, 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.';
|
||||
$passed = $passed && $this->assertEqual((string) $textarea, $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 $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [
|
||||
return $this->assertFalse($select, new FormattableMarkup('Field @id does not exist.', [
|
||||
'@id' => $id,
|
||||
]));
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Verifies theme configuration translation settings.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiThemeTest extends WebTestBase {
|
||||
class ConfigTranslationUiThemeTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -65,7 +65,7 @@ class ConfigTranslationUiThemeTest extends WebTestBase {
|
|||
':label' => 'Install and set as default',
|
||||
':theme' => $theme,
|
||||
]);
|
||||
$this->drupalGet($GLOBALS['base_root'] . $elements[0]['href'], ['external' => TRUE]);
|
||||
$this->drupalGet($GLOBALS['base_root'] . $elements[0]->getAttribute('href'), ['external' => TRUE]);
|
||||
|
||||
$translation_base_url = 'admin/config/development/performance/translate';
|
||||
$this->drupalGet($translation_base_url);
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\config_translation\Tests;
|
||||
namespace Drupal\Tests\config_translation\Functional;
|
||||
|
||||
use Drupal\views_ui\Tests\UITestBase;
|
||||
use Drupal\Tests\views_ui\Functional\UITestBase;
|
||||
|
||||
/**
|
||||
* Visit view list and test if translate is available.
|
||||
|
@ -25,8 +25,8 @@ class ConfigTranslationViewListUiTest extends UITestBase {
|
|||
*/
|
||||
public static $modules = ['config_translation', 'views_ui'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$permissions = [
|
||||
'administer views',
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Translate settings and entities to various languages.
|
||||
*
|
||||
* @group config_translation
|
||||
*/
|
||||
class ConfigTranslationUiTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'config_translation',
|
||||
'contextual',
|
||||
'node',
|
||||
'views',
|
||||
'views_ui',
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests that contextual link related to views.
|
||||
*/
|
||||
public function testViewContextualLink() {
|
||||
$user = $this->drupalCreateUser([
|
||||
'translate configuration',
|
||||
'access contextual links',
|
||||
]);
|
||||
$this->drupalLogin($user);
|
||||
|
||||
$this->drupalGet('node');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual-links');
|
||||
$link = $contextualLinks->findLink('Translate view');
|
||||
$this->assertNotNull($link, 'Translate view contextual link added.');
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,17 +8,23 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n maintenance variables to system.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nSystemMaintenanceTest extends 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}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_i18n_system_maintenance');
|
||||
$this->executeMigration('d6_system_maintenance_translation');
|
||||
}
|
||||
|
||||
/**
|
|
@ -8,17 +8,23 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n_strings site variables to system.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nSystemSiteTest extends 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}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_i18n_system_site');
|
||||
$this->executeMigration('d6_system_site_translation');
|
||||
}
|
||||
|
||||
/**
|
|
@ -9,12 +9,19 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Upgrade i18n variables to user.*.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nUserConfigsTest extends MigrateDrupal6TestBase {
|
||||
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}
|
||||
|
@ -23,7 +30,7 @@ class MigrateI18nUserConfigsTest extends MigrateDrupal6TestBase {
|
|||
parent::setUp();
|
||||
$this->installSchema('locale',
|
||||
['locales_source', 'locales_target', 'locales_location']);
|
||||
$this->executeMigrations(['d6_i18n_user_mail', 'd6_i18n_user_settings']);
|
||||
$this->executeMigrations(['d6_user_mail_translation', 'd6_user_settings_translation']);
|
||||
}
|
||||
|
||||
/**
|
|
@ -8,13 +8,21 @@ use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
|||
* Tests the user profile field instance migration.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
* @group legacy
|
||||
*/
|
||||
class MigrateI18nUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
|
||||
class MigrateUserProfileFieldInstanceTranslationTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@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.
|
||||
|
@ -23,11 +31,11 @@ class MigrateI18nUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
|
|||
$this->executeMigrations([
|
||||
'user_profile_field',
|
||||
'user_profile_field_instance',
|
||||
'd6_i18n_user_profile_field_instance',
|
||||
'd6_user_profile_field_instance_translation',
|
||||
]);
|
||||
$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'));
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migrations of i18n maintenance variable.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateSystemMaintenanceTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_system_maintenance_translation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migrations of i18n maintenance variable.
|
||||
*/
|
||||
public function testSystemMaintenance() {
|
||||
$config = \Drupal::service('language_manager')->getLanguageConfigOverride('is', 'system.maintenance');
|
||||
$this->assertSame('is - This is a custom maintenance mode message.', $config->get('message'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Migrate multilingual site variables.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateSystemSiteTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d7_system_site_translation');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of system (site) variables to system.site.yml.
|
||||
*/
|
||||
public function testSystemSite() {
|
||||
$language_manager = \Drupal::service('language_manager');
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'system.site');
|
||||
$this->assertSame('The Site Name', $config_translation->get('name'));
|
||||
$this->assertSame('fr - The Slogan', $config_translation->get('slogan'));
|
||||
$this->assertSame('node', $config_translation->get('page.403'));
|
||||
$this->assertSame('node', $config_translation->get('page.404'));
|
||||
$this->assertSame('node', $config_translation->get('page.front'));
|
||||
$this->assertSame(NULL, $config_translation->get('admin_compact_mode'));
|
||||
|
||||
$config_translation = $language_manager->getLanguageConfigOverride('is', 'system.site');
|
||||
$this->assertSame('is - The Site Name', $config_translation->get('name'));
|
||||
$this->assertSame('is - The Slogan', $config_translation->get('slogan'));
|
||||
$this->assertSame('node/1', $config_translation->get('page.403'));
|
||||
$this->assertSame('node/6', $config_translation->get('page.404'));
|
||||
$this->assertSame('node/4', $config_translation->get('page.front'));
|
||||
$this->assertNULL($config_translation->get('admin_compact_mode'));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test migration of i18n user variables.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateUserConfigsTranslationTest extends MigrateDrupal7TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'language',
|
||||
'locale',
|
||||
'config_translation',
|
||||
// Required for translation migrations.
|
||||
'migrate_drupal_multilingual',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('locale', [
|
||||
'locales_source',
|
||||
'locales_target',
|
||||
'locales_location',
|
||||
]);
|
||||
$this->executeMigrations([
|
||||
'd7_user_mail_translation',
|
||||
'd7_user_settings_translation',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of i18n user variables to user.mail and user.settings.
|
||||
*/
|
||||
public function testUserConfig() {
|
||||
// Tests migration of i18n user variables to user.mail.yml.
|
||||
$language_manager = \Drupal::service('language_manager');
|
||||
$config = $language_manager->getLanguageConfigOverride('is', 'user.mail');
|
||||
$this->assertSame('is - Are you sure?', $config->get('cancel_confirm.subject'));
|
||||
$this->assertSame('is - A little birdie said you wanted to cancel your account.', $config->get('cancel_confirm.body'));
|
||||
$this->assertSame('is - Fix your password', $config->get('password_reset.subject'));
|
||||
$this->assertSame("is - Nope! You're locked out forever.", $config->get('password_reset.body'));
|
||||
$this->assertSame('is - Gawd made you an account', $config->get('register_admin_created.subject'));
|
||||
$this->assertSame("is - ...and she could take it away.\r\n[site:name], [site:url]", $config->get('register_admin_created.body'));
|
||||
$this->assertSame('is - Welcome!', $config->get('register_no_approval_required.subject'));
|
||||
$this->assertSame('is - You can now log in if you can figure out how to use Drupal!', $config->get('register_no_approval_required.body'));
|
||||
$this->assertSame('is - Soon...', $config->get('register_pending_approval.subject'));
|
||||
$this->assertSame('is - ...you will join our Circle. Let the Drupal flow through you.', $config->get('register_pending_approval.body'));
|
||||
$this->assertSame('is - Your account is approved!', $config->get('status_activated.subject'));
|
||||
$this->assertSame('is - Your account was activated, and there was much rejoicing.', $config->get('status_activated.body'));
|
||||
$this->assertSame('is - BEGONE!', $config->get('status_blocked.subject'));
|
||||
$this->assertSame('is - You no longer please the robot overlords. Go to your room and chill out.', $config->get('status_blocked.body'));
|
||||
$this->assertSame('is - So long, bub', $config->get('status_canceled.subject'));
|
||||
$this->assertSame('is - The gates of Drupal are closed to you. Now you will work in the salt mines.', $config->get('status_canceled.body'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
|
||||
|
||||
// Tests migration of i18n user variables to user.settings.yml.
|
||||
$config = $language_manager->getLanguageConfigOverride('is', 'user.settings');
|
||||
$this->assertSame('is - anonymous', $config->get('anonymous'));
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
|||
*
|
||||
* @covers \Drupal\config_translation\Plugin\migrate\source\d6\I18nProfileField
|
||||
* @group migrate_drupal
|
||||
* @group legacy
|
||||
*/
|
||||
class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
|
@ -41,8 +42,8 @@ class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
|
|||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation'
|
||||
]
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_translation\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests the i18nProfileField source plugin.
|
||||
*
|
||||
* @covers \Drupal\config_translation\Plugin\migrate\source\d6\ProfileFieldTranslation
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class ProfileFieldTranslationTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['config_translation', 'migrate_drupal', 'user'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$test = [];
|
||||
$test[0]['source_data'] = [
|
||||
'profile_fields' => [
|
||||
[
|
||||
'fid' => 42,
|
||||
'title' => 'I love migrations',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
],
|
||||
'i18n_strings' => [
|
||||
[
|
||||
'lid' => 10,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'title',
|
||||
],
|
||||
[
|
||||
'lid' => 11,
|
||||
'objectid' => 'profile_love_migrations',
|
||||
'type' => 'field',
|
||||
'property' => 'explanation',
|
||||
],
|
||||
],
|
||||
'locales_target' => [
|
||||
[
|
||||
'lid' => 10,
|
||||
'translation' => "J'aime les migrations.",
|
||||
'language' => 'fr',
|
||||
],
|
||||
[
|
||||
'lid' => 11,
|
||||
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
|
||||
'language' => 'fr',
|
||||
],
|
||||
],
|
||||
];
|
||||
$test[0]['expected_results'] = [
|
||||
[
|
||||
'property' => 'title',
|
||||
'translation' => "J'aime les migrations.",
|
||||
'language' => 'fr',
|
||||
'fid' => '42',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
[
|
||||
'property' => 'explanation',
|
||||
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
|
||||
'language' => 'fr',
|
||||
'fid' => '42',
|
||||
'name' => 'profile_love_migrations',
|
||||
],
|
||||
];
|
||||
return $test;
|
||||
}
|
||||
|
||||
}
|
|
@ -45,10 +45,17 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
/**
|
||||
* The mocked language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,44 +88,52 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
[$this->getElement(['aaa' => 'bbb']), FALSE],
|
||||
[$this->getElement(['translatable' => FALSE]), FALSE],
|
||||
[$this->getElement(['translatable' => TRUE]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement([]),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]), TRUE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
[$this->getNestedElement([$this->getElement([])]), FALSE],
|
||||
[$this->getNestedElement([$this->getElement(['translatable' => TRUE])]), TRUE],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
FALSE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['iii' => 'jjj']),
|
||||
]),
|
||||
]), FALSE],
|
||||
[$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]),
|
||||
]), TRUE],
|
||||
TRUE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['iii' => 'jjj']),
|
||||
]),
|
||||
]),
|
||||
FALSE,
|
||||
],
|
||||
[
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['aaa' => 'bbb']),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ccc' => 'ddd']),
|
||||
$this->getElement(['eee' => 'fff']),
|
||||
]),
|
||||
$this->getNestedElement([
|
||||
$this->getElement(['ggg' => 'hhh']),
|
||||
$this->getElement(['translatable' => TRUE]),
|
||||
]),
|
||||
]),
|
||||
TRUE,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -84,10 +84,17 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
/**
|
||||
* The mocked language manager.
|
||||
*
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface $language_manager|\PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \Drupal\Core\Language\LanguageManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
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 a new issue