Commit 7ab932fb authored by catch's avatar catch

Issue #2657178 by xjm: Warn about experimental modules on their help pages

parent 5f0b3cb4
......@@ -116,6 +116,11 @@ public function helpPage($name) {
$module_name = $this->moduleHandler()->getName($name);
$build['#title'] = $module_name;
$info = system_get_info('module', $name);
if ($info['package'] === 'Core (Experimental)') {
drupal_set_message($this->t('This module is experimental. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', [':url' => 'https://www.drupal.org/core/experimental']), 'warning');
}
$temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.$name", $this->routeMatch));
if (empty($temp)) {
$build['top']['#markup'] = $this->t('No help is available for module %module.', array('%module' => $module_name));
......
<?php
/**
* @file
* Contains \Drupal\help\Tests\ExperimentalHelpTest.
*/
namespace Drupal\help\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Verifies help for experimental modules.
*
* @group help
*/
class ExperimentalHelpTest extends WebTestBase {
/**
* Modules to enable.
*
* The experimental_module_test module implements hook_help() and is in the
* Core (Experimental) package.
*
* @var array
*/
public static $modules = array('help', 'experimental_module_test', 'help_page_test');
/**
* The admin user.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* {@inheritoc}
*/
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['access administration pages']);
}
/**
* Verifies that a warning message is displayed for experimental modules.
*/
public function testExperimentalHelp() {
$this->drupalLogin($this->adminUser);
$this->drupalGet('admin/help/experimental_module_test');
$this->assertText('This module is experimental.');
// Regular modules should not display the message.
$this->drupalGet('admin/help/help_page_test');
$this->assertNoText('This module is experimental.');
// Ensure the actual help page is displayed to avoid a false positive.
$this->assertResponse(200);
$this->assertText('online documentation for the Help Page Test module');
}
}
name: 'Help Page Test'
type: module
description: 'Module to test the help page.'
package: Testing
version: VERSION
core: 8.x
hidden: true
<?php
/**
* @file
* Help Page Test module to test the help page.
*/
use \Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function help_page_test_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.help_page_test':
// Make the help text conform to core standards. See
// \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp().
return t('Read the <a href=":url">online documentation for the Help Page Test module</a>.', [':url' => 'http://www.example.com']);
}
}
name: 'Experimental Test'
type: module
description: 'Module in the experimental package to test experimental functionality.'
package: Core (Experimental)
version: 8.y.x-unstable
core: 8.x
hidden: true
<?php
/**
* @file
* Experimental Test module to test the Core (Experimental) package.
*/
use \Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function experimental_module_test_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.experimental_module_test':
// Make the help text conform to core standards. See
// \Drupal\system\Tests\Module\InstallUninstallTest::assertHelp().
return t('The Experimental Test module is not done yet. It may eat your data, but you can read the <a href=":url">online documentation for the Experimental Test module</a>.', [':url' => 'http://www.example.com']);
}
}
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