Cascade Core  v0.12-1-g22cbbeb
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
JsonBlockStorage Class Reference

Load block composition from JSON file. More...

Inheritance diagram for JsonBlockStorage:
Inheritance graph

Public Member Functions

 __construct ($storage_opts, $context, $alias, $is_write_allowed)
 Constructor will get options from core.json.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.
 
 deleteBlock ($block)
 Delete block configuration.
 
 blockMTime ($block)
 Get time (unix timestamp) of last modification of the block.
 
- Public Member Functions inherited from ClassBlockStorage
 __construct ($storage_opts, $context, $alias, $is_write_allowed)
 Constructor will get options from core.json.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.
 
 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. More...
 

Protected Attributes

 $is_write_allowed
 Is block storage allowed to store blocks?
 
 $filename_match_regexp = '/^[\/a-zA-Z0-9_]+\.json\.php$/'
 Regular expression to match files containing block classes. More...
 
 $filename_to_block_regexp = '/^\/([\/a-zA-Z0-9_-]+)\.json\.php$/'
 Regular expression to match files containing block classes. More...
 
 $default_block_class = "\\Cascade\\Core\\ProxyBlock"
 Default class used to process a block, when no shebang is not specified.
 
 $shebang_classes = array()
 List of interpreters. More...
 
 $context = null
 Default context from cascade.
 
- Protected Attributes inherited from ClassBlockStorage
 $filename_match_regexp = '/^[\/a-zA-Z0-9_]+\.php$/'
 Regular expression to match files containing block classes.
 
 $filename_to_block_regexp ='/^\/([\/a-zA-Z0-9_-]+)\.php$/'
 Regular expression to convert filename to block name.
 

Detailed Description

Load block composition from JSON file.

Shebang is alias for a class. Instance of this class is then used to interpret loaded block configuration.

/

Todo:
Remove extending ClassBlockStorage (see getKnownBlocks()).

Constructor & Destructor Documentation

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

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

Arguments: $storage_opts - Options loaded from config file $context - Common default context (dependency injection container) passed to all storages, and later also to all blocks.

Implements IBlockStorage.

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.

Implements IBlockStorage.

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 or false.

Implements IBlockStorage.

Here is the call graph for this function:

describeBlock (   $block)

Describe block for documentation generator.

Documentation structure is mostly the same as JSON file where block is stored. Only few fileds must be filled before it is complete. And inputs and outputs are completely different.

/

Todo:
Is this method required? What if we just create requested block and inspect it?

Implements IBlockStorage.

loadBlock (   $block)

Load block configuration.

Returns false if block is not found.

Implements IBlockStorage.

Here is the caller graph for this function:

Member Data Documentation

$filename_match_regexp = '/^[\/a-zA-Z0-9_]+\.json\.php$/'
protected

Regular expression to match files containing block classes.

$filename_to_block_regexp = '/^\/([\/a-zA-Z0-9_-]+)\.json\.php$/'
protected

Regular expression to match files containing block classes.

$shebang_classes = array()
protected

List of interpreters.

Block can specify this alias and change how it will be interpreted.