class ModuleTestController

Same name in other branches
  1. 9 core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php \Drupal\module_test\Controller\ModuleTestController
  2. 8.9.x core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php \Drupal\module_test\Controller\ModuleTestController
  3. 11.x core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php \Drupal\module_test\Controller\ModuleTestController

Controller routines for module_test routes.

Hierarchy

Expanded class hierarchy of ModuleTestController

File

core/modules/system/tests/modules/module_test/src/Controller/ModuleTestController.php, line 10

Namespace

Drupal\module_test\Controller
View source
class ModuleTestController {
    
    /**
     * Returns dynamically invoked hook results for the 'module_test' module.
     *
     * @return array
     *   Renderable array.
     */
    public function hookDynamicLoadingInvoke() {
        $result = \Drupal::moduleHandler()->invoke('module_test', 'test_hook');
        return $result['module_test'];
    }
    
    /**
     * Returns dynamically invoked hook results for all modules.
     *
     * @return array
     *   Renderable array.
     */
    public function hookDynamicLoadingInvokeAll() {
        $result = \Drupal::moduleHandler()->invokeAll('test_hook');
        return $result['module_test'];
    }
    
    /**
     * Returns the result of an autoloaded class's public method.
     *
     * @return array
     *   Renderable array.
     */
    public function testClassLoading() {
        $markup = NULL;
        if (class_exists('Drupal\\module_autoload_test\\SomeClass')) {
            $obj = new SomeClass();
            $markup = $obj->testMethod();
        }
        return [
            '#markup' => $markup,
        ];
    }

}

Members

Title Sort descending Modifiers Object type Summary
ModuleTestController::hookDynamicLoadingInvoke public function Returns dynamically invoked hook results for the 'module_test' module.
ModuleTestController::hookDynamicLoadingInvokeAll public function Returns dynamically invoked hook results for all modules.
ModuleTestController::testClassLoading public function Returns the result of an autoloaded class's public method.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.