Cascade Core  v0.12-1-g22cbbeb
 All Classes Namespaces Functions Variables Pages
Public Member Functions | List of all members
IBlockStorage Interface Reference

Load configuration of blocks. More...

Inheritance diagram for IBlockStorage:
Inheritance graph

Public Member Functions

 __construct ($storage_opts, $context, $alias, $is_write_allowed)
 Constructor will get options from core.ini.php file. More...
 
 isReadOnly ()
 Returns true if there is no way that this storage can modify or create blocks. More...
 
 createBlockInstance ($block)
 Create instance of requested block and give it loaded configuration. More...
 
 describeBlock ($block)
 Describe block for documentation generator. More...
 
 loadBlock ($block)
 Load block configuration. More...
 
 storeBlock ($block, $config)
 Store block configuration. More...
 
 deleteBlock ($block)
 Delete block configuration.
 
 blockMTime ($block)
 Get time (unix timestamp) of last modification of the block.
 
 getKnownBlocks (&$blocks=array())
 List all available blocks in this storage.
 

Detailed Description

Load configuration of blocks.

It allows loading blocks from many different storages like simple INI files, SQL database or cloud blob storage.

Constructor & Destructor Documentation

__construct (   $storage_opts,
  $context,
  $alias,
  $is_write_allowed 
)

Constructor will get options from core.ini.php file.

Parameters
$storage_optsOptions loaded from config file
$contextCommon default context (dependency injection container) passed to all storages, and later also to all blocks.
$aliasName of the storage (use it in error messages)
$is_write_allowedIf false, block storage is not allowed to store or update any blocks.

Implemented in JsonBlockStorage, and ClassBlockStorage.

Member Function Documentation

isReadOnly ( )

Returns true if there is no way that this storage can modify or create blocks.

When creating or modifying block, first storage that returns true will be used.

Implemented in JsonBlockStorage, and ClassBlockStorage.

createBlockInstance (   $block)

Create instance of requested block and give it loaded configuration.

No further initialisation here, that is job for cascade controller. Returns created instance, block configuration (array) or false.

If block configuration is returned, CascadeController will execute shebang handler to create instance of the Block using this configuration.

Implemented in JsonBlockStorage, and ClassBlockStorage.

describeBlock (   $block)

Describe block for documentation generator.

Returns structure similar to JSON files in which composed blocks are stored.

In contrast to loadBlock() method, the describeBlock() may return significantly modified structure. Or completely artificial structure generated only for documentation purposes.

Warning
Never pass result of describeBlock() to storeBlock().

/

Todo:
Document the documentation structure.
Deprecated:
Blocks should describe themself. It is bad idea to have this here.

Implemented in JsonBlockStorage, and ClassBlockStorage.

loadBlock (   $block)

Load block configuration.

Returns false if block is not found.

Structure returned by loadBlock() can be directly stored by storeBlock(). The block editors are expected to load a block using loadBlock(), modify the structure, and then store it back using storeBlock(). Therefore, loadBlock() and storeBlock() are complementary pair.

Implemented in JsonBlockStorage, and ClassBlockStorage.

storeBlock (   $block,
  $config 
)

Store block configuration.

Use loadBlock() to retrive block configuration, or create a new block.

Implemented in JsonBlockStorage, and ClassBlockStorage.