Commit 2b08f2ec authored by alexpott's avatar alexpott

Issue #1978928 by piyuesh23, InternetDevels, disasm: Convert...

Issue #1978928 by piyuesh23, InternetDevels, disasm: Convert locale_translation_manual_status() to a Controller.
parent 324631dd
<?php
/**
* @file
* Contains \Drupal\locale\Controller\LocaleController.
*/
namespace Drupal\locale\Controller;
use Drupal\Core\Controller\ControllerInterface;
use Drupal\Core\Routing\PathBasedGeneratorInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Return response for manual check translations.
*/
class LocaleController implements ControllerInterface {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a \Drupal\locale\Controller\LocaleController object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(ModuleHandlerInterface $module_handler, PathBasedGeneratorInterface $url_generator) {
$this->moduleHandler = $module_handler;
$this->urlGenerator = $url_generator;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('module_handler'),
$container->get('url_generator')
);
}
/**
* 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)));
}
}
......@@ -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;
}
......
......@@ -468,30 +468,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.
*
......
......@@ -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'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment