diff --git a/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php new file mode 100644 index 0000000..ffffc78 --- /dev/null +++ b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php @@ -0,0 +1,71 @@ +moduleHandler = $module_handler; + $this->urlGenerator = $url_generator; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('module_handler') + ); + } + + /** + * Checks for translation updates and displays the translations status. + * + * Manually checks the translation status without the use of cron. + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse + * A redirection to translations reports page. + */ + public function checkTranslation() { + $this->moduleHandler->loadInclude('locale', 'inc', 'locale.compare'); + + // Check translation status of all translatable project in all languages. + // First we clear the cached list of projects. Although not strictly + // nescessary, this is helpfull in case the project list is out of sync. + locale_translation_flush_projects(); + locale_translation_check_projects(); + + // Execute a batch if required. A batch is only used when remote files + // are checked. + if (batch_get()) { + return batch_process('admin/reports/translations'); + } + + return new RedirectResponse($this->urlGenerator->generateFromPath('admin/reports/translations', array('absolute' => TRUE))); + } +} diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 8d6ff20..932b2a1 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -215,13 +215,6 @@ function locale_menu() { 'access arguments' => array('translate interface'), 'file' => 'locale.pages.inc', ); - $items['admin/reports/translations/check'] = array( - 'title' => 'Manual translation update check', - 'page callback' => 'locale_translation_manual_status', - 'access arguments' => array('translate interface'), - 'type' => MENU_CALLBACK, - 'file' => 'locale.pages.inc', - ); return $items; } diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 6326905..83777b6 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -469,30 +469,6 @@ function locale_translate_edit_form_submit($form, &$form_state) { } /** - * Page callback: Checks for translation updates and displays the translations status. - * - * Manually checks the translation status without the use of cron. - * - * @see locale_menu() - */ -function locale_translation_manual_status() { - module_load_include('compare.inc', 'locale'); - - // Check translation status of all translatable project in all languages. - // First we clear the cached list of projects. Although not strictly - // nescessary, this is helpfull in case the project list is out of sync. - locale_translation_flush_projects(); - locale_translation_check_projects(); - - // Execute a batch if required. A batch is only used when remote files - // are checked. - if (batch_get()) { - return batch_process('admin/reports/translations'); - } - return new RedirectResponse(url('admin/reports/translations', array('absolute' => TRUE))); -} - -/** * Page callback: Display the current translation status. * * @see locale_menu() diff --git a/core/modules/locale/locale.routing.yml b/core/modules/locale/locale.routing.yml index a2a5820..2047229 100644 --- a/core/modules/locale/locale.routing.yml +++ b/core/modules/locale/locale.routing.yml @@ -4,3 +4,10 @@ locale_settings: _form: 'Drupal\locale\Form\LocaleSettingsForm' requirements: _permission: 'translate interface' + +locale_check_translation: + pattern: '/admin/reports/translations/check' + defaults: + _controller: 'Drupal\locale\Controller\LocaleController::checkTranslation' + requirements: + _permission: 'translate interface'