BlockRepository Class Reference
The block repository allows naming of blocks and easy enabling/disableing them. More...
Static Public Member Functions |
|
static | add ($key, IBlock $block) |
Add a block. |
|
static | enable (PageData $page_data, $position, $blocks, $start_index=1000, $increment=10) |
Enable given blocks for given position.
|
|
static | get ($key) |
Retrieve block for key. |
Detailed Description
The block repository allows naming of blocks and easy enabling/disableing them.
Definition at line 8 of file blockrepository.cls.php.
Member Function Documentation
static BlockRepository::add | ( | $ | key, | |
IBlock $ | block | |||
) | [static] |
Add a block.
- Parameters:
-
string $key Name of block, used as key IBlock $block
Definition at line 17 of file blockrepository.cls.php.
static BlockRepository::enable | ( | PageData $ | page_data, | |
$ | position, | |||
$ | blocks, | |||
$ | start_index =
1000 , |
|||
$ | increment = 10 |
|||
) | [static] |
Enable given blocks for given position.
- Parameters:
-
PageData $page_data string $position LEFT, RIGHT etc array $keys Keys of blocks to enable OR array of IBlock or mixed int $start_index Index of first block int $increment Index of blocks get incremented by this
Definition at line 40 of file blockrepository.cls.php.
00040 { 00041 $enable_blocks = array(); 00042 foreach(Arr::force($blocks) as $key) { 00043 if ($key instanceof IBlock) { 00044 $enable_blocks[] = $key; 00045 } 00046 else { 00047 $block = self::get($key); 00048 if ($block) { 00049 $enable_blocks[] = $block; 00050 } 00051 } 00052 } 00053 // Now enable them 00054 foreach($enable_blocks as $block) { 00055 $page_data->add_block($block, $position, $start_index); 00056 $start_index += $increment; 00057 } 00058 }
static BlockRepository::get | ( | $ | key | ) | [static] |
Retrieve block for key.
- Parameters:
-
string $key
- Returns:
- IBlock
Definition at line 27 of file blockrepository.cls.php.
00027 { 00028 return Arr::get_item(self::$blocks, $key, false); 00029 }
The documentation for this class was generated from the following file:
- contributions/page.blocks/lib/components/blockrepository.cls.php