private static function Blocks::load in Hook Update Deploy Tools 7
Loads a block object.
Parameters
string $module: The machine name of the module that created the block. Use 'block' if was one created in the block UI.
string $block_delta: the block delta (machine name of the block)
string $theme: The name of the theme to target. Defaults to default theme.
Return value
object The block object that was loaded.
Throws
HudtException If the block fails to load.
3 calls to Blocks::load()
- Blocks::disable in src/
Blocks.php - Disables a block for a specific theme.
- Blocks::enable in src/
Blocks.php - Enables and sets the region for a block in a specific theme.
- Blocks::updateInstanceProperties in src/
Blocks.php - Updates a block with any specified properties.
File
- src/
Blocks.php, line 199
Class
- Blocks
- Public methods for working with Blocks.
Namespace
HookUpdateDeployToolsCode
private static function load($module, $block_delta, $theme = NULL) {
// Gather the theme.
$theme = !empty($theme) ? $theme : variable_get('theme_default', NULL);
Check::notEmpty('$theme', $theme);
Check::notEmpty('$module', $module);
Check::notEmpty('$delta', $block_delta);
$params = array(
':module' => $module,
':delta' => $block_delta,
':theme' => $theme,
);
$block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme', $params)
->fetchObject();
if (!empty($block)) {
return $block;
}
else {
// Came up empty.
$vars = array(
'@module' => $module,
'@delta' => $block_delta,
'@theme' => $theme,
);
$message = 'Trying to load block @module:@delta from theme:@theme found no block.';
throw new HudtException($message, $vars, WATCHDOG_ERROR, TRUE);
}
}