vardumper_block.module in VarDumper 7
Same filename and directory in other branches
Main module file for the vardumper_block module.
File
modules/vardumper_block/vardumper_block.moduleView source
<?php
/**
* @file
* Main module file for the vardumper_block module.
*/
/**
* Implements hook_block_info().
*/
function vardumper_block_block_info() {
return array(
'vardumper' => array(
'info' => 'Debugging block',
'cache' => DRUPAL_NO_CACHE,
),
);
}
/**
* Implements hook_block_view().
*/
function vardumper_block_block_view($delta = '') {
$content = NULL;
$block = array();
$items = array();
// Do not display anything if user do not have the permission.
if (!user_access('access vardumper information')) {
return array(
'subject' => t('Debugging block'),
'content' => NULL,
);
}
/* @var \Symfony\Component\HttpFoundation\Session\Session $session */
$session = \Drupal::service('vardumper_session');
foreach ($session
->getFlashBag()
->get('vardumper', array()) as $message) {
$items[] = $message;
}
if (!empty($items)) {
$content = array(
'#theme' => 'item_list',
'#items' => $items,
);
}
switch ($delta) {
case 'vardumper':
$block['subject'] = t('Debugging block');
$block['content'] = $content;
}
return $block;
}
/**
* API aliases.
*/
function vardumperBlock($var, $name = '') {
vardumper($var, $name, 'block');
}
/**
* API aliases.
*/
function vdpb($var, $name = '') {
vardumper($var, $name, 'block');
}
Functions
Name | Description |
---|---|
vardumperBlock | API aliases. |
vardumper_block_block_info | Implements hook_block_info(). |
vardumper_block_block_view | Implements hook_block_view(). |
vdpb | API aliases. |