function plug_example_test_page_content in Plug 7
Generates the plug_example page content.
Parameters
\Drupal\Component\Plugin\PluginManagerInterface $manager: The Plugin manager.
Return value
array The test page render array.
2 calls to plug_example_test_page_content()
- plug_example_annotation_test_page in modules/
plug_example/ plug_example.module - Page callback to test annotation the plugins.
- plug_example_yaml_test_page in modules/
plug_example/ plug_example.module - Page callback to test the plugins.
File
- modules/
plug_example/ plug_example.module, line 90 - Module implementation file.
Code
function plug_example_test_page_content($manager, $method) {
$items = array();
foreach ($manager
->getDefinitions() as $id => $plugin) {
// This is just a silly way to show how you can pass arbitrary configuration
// at runtime. If true, the name will be wrapped in <em></em>.
$random_bool = (bool) floor(mt_rand(0, 2));
$instance = $manager
->createInstance($id, array(
'em' => $random_bool,
));
$items[] = $instance
->{$method}() . '<br /><pre>' . var_export($instance, TRUE) . '</pre>';
}
return array(
'#theme' => 'item_list',
'#items' => $items,
);
}