service_container_block.module in Service Container 7.2
Same filename and directory in other branches
Main module file for the service_container_block module.
File
modules/utility/service_container_block/service_container_block.moduleView source
<?php
/**
* @file
* Main module file for the service_container_block module.
*/
/**
* Implements hook_block_info().
*/
function service_container_block_block_info() {
$blocks = array();
$plugin_manager = \Drupal::service('plugin.manager.block');
foreach ($plugin_manager
->getDefinitions() as $definition) {
if (strlen($definition['id']) <= 32) {
$blocks[$definition['id']]['info'] = $definition['admin_label'];
}
}
return $blocks;
}
/**
* Implements hook_block_view().
*/
function service_container_block_block_view($delta = '') {
$definition = \Drupal::service('plugin.manager.block')
->getDefinition($delta);
if ($definition) {
$block = \Drupal::service('plugin.manager.block')
->createInstance($delta);
return array(
'content' => $block
->build(),
);
}
}
Functions
Name | Description |
---|---|
service_container_block_block_info | Implements hook_block_info(). |
service_container_block_block_view | Implements hook_block_view(). |