function mongodb_block_ui_block_info in MongoDB 7
Implements hook_block_info().
This function loads custom blocks.
File
- mongodb_block_ui/
mongodb_block_ui.module, line 141 - Controls the visual building mongodb_block_uis a page is constructed with.
Code
function mongodb_block_ui_block_info() {
$blocks = array();
$collection = mongodb_collection('block_custom');
$result = $collection
->find(array(), array(
'info',
'_id',
))
->sort(array(
'info' => 1,
));
$blocks = new stdClass();
foreach ($result as $block) {
$delta = $block['_id'];
// Here comes the magic... by using an object we can have string array
// keys later when we cast to array.
$blocks->{$delta} = array(
'info' => $block['info'],
// Not worth caching.
'cache' => DRUPAL_NO_CACHE,
'status' => TRUE,
);
}
// Here , the $delta becomes a string.
return (array) $blocks;
}