Issue #2405939 by Gábor Hojtsy, olli: use_current_language upcasting option is misleading, it toggles all overrides not just language

8.0.x
Alex Pott 2015-01-22 15:01:18 +00:00
parent f067cd5a81
commit cc9d0f9646
4 changed files with 19 additions and 14 deletions

View File

@ -19,7 +19,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
* converting to entities with overrides, such as the negotiated language.
*
* This converter applies only if the path is an admin path, the entity is
* a config entity, and the "use_current_language" element is not set to TRUE
* a config entity, and the "with_config_overrides" element is not set to TRUE
* on the parameter definition.
*
* Due to this converter having a higher weight than the default
@ -86,7 +86,7 @@ class AdminPathConfigEntityConverter extends EntityConverter {
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
if (isset($definition['use_current_language']) && $definition['use_current_language']) {
if (isset($definition['with_config_overrides']) && $definition['with_config_overrides']) {
return FALSE;
}

View File

@ -30,4 +30,4 @@ language_test.entity_using_current_language:
configurable_language:
type: entity:configurable_language
# Force load in current interface language.
use_current_language: 'TRUE'
with_config_overrides: TRUE

View File

@ -28,7 +28,7 @@ node.add:
_node_operation_route: TRUE
parameters:
node_type:
use_current_language: TRUE
with_config_overrides: TRUE
entity.node.preview:
path: '/node/preview/{node_preview}/{view_mode_id}'

View File

@ -322,15 +322,20 @@
* Configuration entity classes expose dependencies by overriding the
* \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies()
* method.
* - On routes for paths staring with '\admin' with configuration entity
* placeholders, configuration entities are normally loaded in their original
* language, not translated. This is usually desirable, because most admin
* paths are for editing configuration, and you need that to be in the source
* language. If for some reason you need to have your configuration entity
* loaded in the currently-selected language on an admin path (for instance,
* if you go to example.com/es/admin/your_path and you need the entity to be
* in Spanish), then you can add a 'use_current_language' parameter option to
* your route. Here's an example using the configurable_language config
* - On routes for paths staring with '/admin' or otherwise designated as
* administration paths (such as node editing when it is set as an admin
* operation), if they have configuration entity placeholders, configuration
* entities are normally loaded in their original language, without
* translations or other overrides. This is usually desirable, because most
* admin paths are for editing configuration, and you need that to be in the
* source language and to lack possibly dynamic overrides. If for some reason
* you need to have your configuration entity loaded in the currently-selected
* language on an admin path (for instance, if you go to
* example.com/es/admin/your_path and you need the entity to be in Spanish),
* then you can add a 'with_config_overrides' parameter option to your route.
* The same applies if you need to load the entity with overrides (or
* translated) on an admin path like '/node/add/article' (when configured to
* be an admin path). Here's an example using the configurable_language config
* entity:
* @code
* mymodule.myroute:
@ -341,7 +346,7 @@
* parameters:
* configurable_language:
* type: entity:configurable_language
* use_current_language: 'TRUE'
* with_config_overrides: TRUE
* @endcode
* With the route defined this way, the $configurable_language parameter to
* your controller method will come in translated to the current language.