Issue #2342015 by Chi, joelpittet, vijaycs85, Matt V., Gábor Hojtsy, alexpott, catch: Content Translation module still implements hook_enable

8.1.x
Alex Pott 2016-02-26 11:12:40 +00:00
parent c3707e1511
commit d5af25512e
3 changed files with 12 additions and 10 deletions

View File

@ -5,6 +5,8 @@
* Installation functions for Content Translation module.
*/
use \Drupal\Core\Url;
/**
* Implements hook_install().
*/
@ -12,20 +14,15 @@ function content_translation_install() {
// Assign a fairly low weight to ensure our implementation of
// hook_module_implements_alter() is run among the last ones.
module_set_weight('content_translation', 10);
}
/**
* Implements hook_enable().
*/
function content_translation_enable() {
// Translation works when at least two languages are added.
if (count(\Drupal::languageManager()->getLanguages()) < 2) {
$t_args = array(':language_url' => \Drupal::url('entity.configurable_language.collection'));
// @todo: Switch to Url::fromRoute() once https://www.drupal.org/node/2589967 is resolved.
$t_args = [':language_url' => Url::fromUri('internal:/admin/config/regional/language')->toString()];
$message = t('This site has only a single language enabled. <a href=":language_url">Add at least one more language</a> in order to translate content.', $t_args);
drupal_set_message($message, 'warning');
}
// Point the user to the content translation settings.
$t_args = array(':settings_url' => \Drupal::url('language.content_settings_page'));
$t_args = [':settings_url' => Url::fromUri('internal:/admin/config/regional/content-language')->toString()];
$message = t('<a href=":settings_url">Enable translation</a> for <em>content types</em>, <em>taxonomy vocabularies</em>, <em>accounts</em>, or any other element you wish to translate.', $t_args);
drupal_set_message($message, 'warning');
}

View File

@ -10,7 +10,7 @@ namespace Drupal\content_translation\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Test enabling content translation after other modules.
* Test enabling content translation module.
*
* @group content_translation
*/
@ -34,6 +34,10 @@ class ContentTranslationEnableTest extends WebTestBase {
];
$this->drupalPostForm('admin/modules', $edit, t('Install'));
// Status messages are shown.
$this->assertText(t('This site has only a single language enabled. Add at least one more language in order to translate content.'));
$this->assertText(t('Enable translation for content types, taxonomy vocabularies, accounts, or any other element you wish to translate.'));
// No pending updates should be available.
$this->drupalGet('admin/reports/status');
$requirement_value = $this->cssSelect("tr.system-status-report__entry th:contains('Entity/field definitions') + td");

View File

@ -47,7 +47,8 @@ class HelpEmptyPageTest extends KernelTestBase {
return TRUE;
});
\Drupal::service('module_installer')->install(array_keys($all_modules));
$this->enableModules(array_keys($all_modules));
$this->installEntitySchema('menu_link_content');
$route = \Drupal::service('router.route_provider')->getRouteByName('<front>');
\Drupal::service('module_handler')->invokeAll('help', ['<front>', new RouteMatch('<front>', $route)]);