View source
<?php
use Drupal\Core\Extension\Extension;
use Drupal\Core\Routing\RouteMatchInterface;
function system_test_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.system_test':
$output = '';
$output .= '<h3>' . t('Test Help Page') . '</h3>';
$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;
}
}
function system_test_modules_installed($modules) {
if (\Drupal::state()
->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
drupal_set_message(t('hook_modules_installed fired for @module', array(
'@module' => $module,
)));
}
}
}
function system_test_modules_uninstalled($modules) {
if (\Drupal::state()
->get('system_test.verbose_module_hooks')) {
foreach ($modules as $module) {
drupal_set_message(t('hook_modules_uninstalled fired for @module', array(
'@module' => $module,
)));
}
}
}
function system_test_system_info_alter(&$info, Extension $file, $type) {
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';
}
}
if ($file
->getName() == 'system_dependencies_test') {
$info['hidden'] = FALSE;
}
if (in_array($file
->getName(), array(
'system_incompatible_module_version_dependencies_test',
'system_incompatible_core_version_dependencies_test',
'system_incompatible_module_version_test',
'system_incompatible_core_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);
}
}
function system_test_page_attachments(array &$page) {
$frontpage = \Drupal::state()
->get('system_test.front_page_output') ?: 0;
if ($frontpage && \Drupal::service('path.matcher')
->isFrontPage()) {
drupal_set_message(t('On front page.'));
}
}
function _system_test_first_shutdown_function($arg1, $arg2) {
\Drupal::state()
->set('_system_test_first_shutdown_function', array(
$arg1,
$arg2,
));
drupal_register_shutdown_function('_system_test_second_shutdown_function', $arg1, $arg2);
}
function _system_test_second_shutdown_function($arg1, $arg2) {
\Drupal::state()
->set('_system_test_second_shutdown_function', array(
$arg1,
$arg2,
));
throw new Exception('Drupal is <blink>awesome</blink>.');
}
function system_test_filetransfer_info() {
return array(
'system_test' => array(
'title' => t('System Test FileTransfer'),
'class' => 'Drupal\\system_test\\MockFileTransfer',
'weight' => -10,
),
);
}
function system_test_module_preinstall($module) {
\Drupal::state()
->set('system_test_preinstall_module', $module);
}
function system_test_module_preuninstall($module) {
\Drupal::state()
->set('system_test_preuninstall_module', $module);
}