class SystemTestHooks
Hook implementations for system_test.
Hierarchy
- class \Drupal\system_test\Hook\SystemTestHooks
Expanded class hierarchy of SystemTestHooks
1 file declares its use of SystemTestHooks
- DrupalFlushAllCachesTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Common/ DrupalFlushAllCachesTest.php
File
-
core/
modules/ system/ tests/ modules/ system_test/ src/ Hook/ SystemTestHooks.php, line 14
Namespace
Drupal\system_test\HookView source
class SystemTestHooks {
/**
* Implements hook_help().
*/
public function help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.system_test':
$output = '';
$output .= '<h2>' . t('Test Help Page') . '</h2>';
$output .= '<p>' . t('This is a test help page for the system_test module for the purpose of testing if the "Help" link displays properly.') . '</p>';
return $output;
}
}
/**
* Implements hook_modules_installed().
*/
public function modulesInstalled($modules) {
if (\Drupal::state()->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
\Drupal::messenger()->addStatus(t('hook_modules_installed fired for @module', [
'@module' => $module,
]));
}
}
}
/**
* Implements hook_modules_uninstalled().
*/
public function modulesUninstalled($modules, $is_syncing) {
if (\Drupal::state()->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
\Drupal::messenger()->addStatus(t('hook_modules_uninstalled fired for @module', [
'@module' => $module,
]));
}
}
// Save the config.installer isSyncing() value to state to check that it is
// correctly set when installing module during config import.
\Drupal::state()->set('system_test_modules_uninstalled_config_installer_syncing', \Drupal::service('config.installer')->isSyncing());
// Save the $is_syncing parameter value to state to check that it is correctly
// set when installing module during config import.
\Drupal::state()->set('system_test_modules_uninstalled_syncing_param', $is_syncing);
}
/**
* Implements hook_system_info_alter().
*/
public function systemInfoAlter(&$info, Extension $file, $type) {
// We need a static otherwise the last test will fail to alter common_test.
static $test;
if (($dependencies = \Drupal::state()->get('system_test.dependencies')) || $test) {
if ($file->getName() == 'module_test') {
$info['hidden'] = FALSE;
$info['dependencies'][] = array_shift($dependencies);
\Drupal::state()->set('system_test.dependencies', $dependencies);
$test = TRUE;
}
if ($file->getName() == 'common_test') {
$info['hidden'] = FALSE;
$info['version'] = '8.x-2.4-beta3';
}
}
// Make the system_dependencies_test visible by default.
if ($file->getName() == 'system_dependencies_test') {
$info['hidden'] = FALSE;
}
if (in_array($file->getName(), [
'system_incompatible_module_version_dependencies_test',
'system_incompatible_core_version_dependencies_test',
'system_incompatible_module_version_test',
])) {
$info['hidden'] = FALSE;
}
if ($file->getName() == 'requirements1_test' || $file->getName() == 'requirements2_test') {
$info['hidden'] = FALSE;
}
if ($file->getName() == 'system_test') {
$info['hidden'] = \Drupal::state()->get('system_test.module_hidden', TRUE);
}
}
/**
* Implements hook_page_attachments().
*/
public function pageAttachments(array &$page) {
// Used by FrontPageTestCase to get the results of
// \Drupal::service('path.matcher')->isFrontPage().
$frontpage = \Drupal::state()->get('system_test.front_page_output', 0);
if ($frontpage && \Drupal::service('path.matcher')->isFrontPage()) {
\Drupal::messenger()->addStatus(t('On front page.'));
}
}
/**
* Implements hook_filetransfer_info().
*/
public function filetransferInfo() {
return [
'system_test' => [
'title' => t('System Test FileTransfer'),
'class' => 'Drupal\\system_test\\MockFileTransfer',
'weight' => -10,
],
];
}
/**
* Implements hook_module_preinstall().
*/
public function modulePreinstall($module, bool $is_syncing) {
\Drupal::messenger()->addStatus('system_test_preinstall_module called');
\Drupal::state()->set('system_test_preinstall_module', $module);
// Save the config.installer isSyncing() value to state to check that it is
// correctly set when installing module during config import.
\Drupal::state()->set('system_test_preinstall_module_config_installer_syncing', \Drupal::service('config.installer')->isSyncing());
// Save the $is_syncing parameter value to state to check that it is correctly
// set when installing module during config import.
\Drupal::state()->set('system_test_preinstall_module_syncing_param', $is_syncing);
}
/**
* Implements hook_module_preuninstall().
*/
public function modulePreuninstall($module, bool $is_syncing) {
\Drupal::state()->set('system_test_preuninstall_module', $module);
// Save the config.installer isSyncing() value to state to check that it is
// correctly set when uninstalling module during config import.
\Drupal::state()->set('system_test_preuninstall_module_config_installer_syncing', \Drupal::service('config.installer')->isSyncing());
// Save the $is_syncing parameter value to state to check that it is correctly
// set when installing module during config import.
\Drupal::state()->set('system_test_preuninstall_module_syncing_param', $is_syncing);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
SystemTestHooks::filetransferInfo | public | function | Implements hook_filetransfer_info(). |
SystemTestHooks::help | public | function | Implements hook_help(). |
SystemTestHooks::modulePreinstall | public | function | Implements hook_module_preinstall(). |
SystemTestHooks::modulePreuninstall | public | function | Implements hook_module_preuninstall(). |
SystemTestHooks::modulesInstalled | public | function | Implements hook_modules_installed(). |
SystemTestHooks::modulesUninstalled | public | function | Implements hook_modules_uninstalled(). |
SystemTestHooks::pageAttachments | public | function | Implements hook_page_attachments(). |
SystemTestHooks::systemInfoAlter | public | function | Implements hook_system_info_alter(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.