Skip to content
Snippets Groups Projects
Commit cb07e913 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1999444 by chertzog: Use Symfony Request for translation module.

parent fa9c197e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -122,9 +122,12 @@ function translation_permission() {
* Implements hook_node_access().
*/
function translation_node_access($node, $op, $account, $langcode) {
$request_has_translation_arg = isset($_GET['translation']) && isset($_GET['target']) && is_numeric($_GET['translation']);
$query = Drupal::request()->query;
$translation = $query->get('translation');
$target = $query->get('target');
$request_has_translation_arg = !empty($translation) && !empty($target) && is_numeric($translation);
if ($op == 'create' && $request_has_translation_arg) {
$source_node = node_load($_GET['translation']);
$source_node = node_load($translation);
if (empty($source_node) || !translation_user_can_translate_node($source_node, $account)){
return NODE_ACCESS_DENY;
}
......@@ -304,19 +307,22 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v
* Implements hook_node_prepare().
*/
function translation_node_prepare(EntityInterface $node) {
$query = Drupal::request()->query;
$translation = $query->get('translation');
$target = $query->get('target');
// Only act if we are dealing with a content type supporting translations.
if (translation_supported_type($node->type) &&
// And it's a new node.
empty($node->nid) &&
// And the $_GET variables are set properly.
isset($_GET['translation']) &&
isset($_GET['target']) &&
is_numeric($_GET['translation'])) {
// And the request variables are set properly.
!empty($translation) &&
!empty($target) &&
is_numeric($translation)) {
$source_node = node_load($_GET['translation']);
$source_node = node_load($translation);
$language_list = language_list();
$langcode = $_GET['target'];
$langcode = $target;
if (!isset($language_list[$langcode]) || ($source_node->langcode == $langcode)) {
// If not supported language, or same language as source node, break.
return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment