Commit 12226d9c authored by webchick's avatar webchick
Browse files

Issue #1987804 by disasm, dawehner: Convert plugin_test_definitions() to a new style controller.

parent 32eb0bc9
<?php
/**
* @file
* Contains \Drupal\plugin_test\Controller\PluginTest.
*/
namespace Drupal\plugin_test\Controller;
use Drupal\plugin_test\Plugin\CachedMockBlockManager;
/**
* Returns a test page containing plugin labels.
*/
class PluginTest {
/**
* Prints plugin labels for testing.
*
* @return array
* A renderable array of plugin labels.
*/
public function testDefinitions() {
$manager = new CachedMockBlockManager();
$output = array();
foreach ($manager->getDefinitions() as $plugin_id => $definition) {
$output[$plugin_id] = array(
'#markup' => $definition['label'],
);
}
return $output;
}
}
<?php
use Drupal\plugin_test\Plugin\CachedMockBlockManager;
/**
* @file
* Helper module for the plugin tests.
......@@ -23,25 +21,7 @@ function plugin_test_plugin_test_alter(&$definitions) {
function plugin_test_menu() {
$items = array();
$items['plugin_definition_test'] = array(
'access callback' => TRUE,
'page callback' => 'plugin_test_definitions',
'route_name' => 'plugin_test_definitions',
);
return $items;
}
/**
* A simple page callback that prints plugin labels for testing.
*
* @return array
* A simple renderable array of plugin labels.
*/
function plugin_test_definitions() {
$manager = new CachedMockBlockManager();
$output = array();
foreach($manager->getDefinitions() as $plugin_id => $definition) {
$output[$plugin_id] = array(
'#markup' => $definition['label'],
);
}
return $output;
}
plugin_definition_test:
pattern: '/plugin_definition_test'
defaults:
_content: '\Drupal\plugin_test\Controller\PluginTest::testDefinitions'
requirements:
_access: 'TRUE'
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