Interface luya\cms\base\BlockInterface
Implemented by | luya\cms\base\InternalBaseBlock, luya\cms\base\PhpBlock, luya\cms\frontend\blocks\HtmlBlock, luya\cms\frontend\blocks\MirrorLanguageBlock, luya\cms\frontend\blocks\ModuleBlock |
---|---|
Available since version | 1.0.0 |
Source Code | https://github.com/luyadev/luya-module-cms/blob/master/src/base/BlockInterface.php |
Interface for all Blocks.
The below methods are required in order to create your own block abstraction layer.
Public Methods
Method | Description | Defined By |
---|---|---|
blockGroup() | Returns a class of the blocks group. | luya\cms\base\BlockInterface |
getCacheExpirationTime() | The time of cache expiration | luya\cms\base\BlockInterface |
getConfigCfgsExport() | Returns all config cfgs element of key value pairing to pass to the Admin ANGULAR API | luya\cms\base\BlockInterface |
getConfigPlaceholdersByRowsExport() | Returns the placeholder based rows. | luya\cms\base\BlockInterface |
getConfigPlaceholdersExport() | Returns all config placeholders element of key value pairing to pass to the Admin ANGULAR API | luya\cms\base\BlockInterface |
getConfigVarsExport() | Returns all config vars element of key value pairing to pass to the Admin ANGULAR API | luya\cms\base\BlockInterface |
getExtraVarValues() | Returns an array of key value pairing with additional informations to pass to the API and frontend. | luya\cms\base\BlockInterface |
getFieldHelp() | Returns an array with additional help informations for specific field (var or cfg). | luya\cms\base\BlockInterface |
getIsCacheEnabled() | Whether cache is enabled for this block or not. | luya\cms\base\BlockInterface |
getIsContainer() | Whether this is a container element or not. Container elements usually have defined placeholders. | luya\cms\base\BlockInterface |
getIsDirtyDialogEnabled() | Whether the dirty marker dialog is enable or not. | luya\cms\base\BlockInterface |
icon() | Returns the icon based on material icon names | luya\cms\base\BlockInterface |
name() | Get the name of the block in order to display in administration context. | luya\cms\base\BlockInterface |
onRegister() | Will called when the block is saved to the cache. | luya\cms\base\BlockInterface |
onRegisterFromCache() | Will called when the block is loaded from the cache. | luya\cms\base\BlockInterface |
placeholderRenderIteration() | This method is called whenever a block inside a placeholder is rendered. | luya\cms\base\BlockInterface |
renderAdmin() | Get the output in administration context. | luya\cms\base\BlockInterface |
renderAdminPreview() | Create a html img tag and use the preview image at {module}/resources/img/{block-name}.jpg as source. | luya\cms\base\BlockInterface |
renderFrontend() | Get the output in the frontend context. | luya\cms\base\BlockInterface |
setCfgValues() | Set the values for element cfgs with an array key value binding. | luya\cms\base\BlockInterface |
setEnvOption() | Set an environment option informations to the block with key value pairing. | luya\cms\base\BlockInterface |
setPlaceholderValues() | Set the value from placeholders where the array key is the name of value the content of the placeholder. | luya\cms\base\BlockInterface |
setVarValues() | Set the values for element vars with an array key value binding. | luya\cms\base\BlockInterface |
setup() | This method is run when the block object is initialized in frontend context. | luya\cms\base\BlockInterface |
Method Details
Returns a class of the blocks group.
public abstract luya\cms\base\BlockGroup blockGroup ( ) |
public function blockGroup();
The time of cache expiration
public abstract integer getCacheExpirationTime ( ) |
public function getCacheExpirationTime();
Returns all config cfgs element of key value pairing to pass to the Admin ANGULAR API
public abstract array getConfigCfgsExport ( ) |
public function getConfigCfgsExport();
Returns the placeholder based rows.
This is used to render the grid system in the admin ui.
The array which is returned contains rows which contains cols.
return [
[], // row 1
[], // row 2
];
each row can contain columns
return [
[ // row 1
['var' => 'left', 'col' => 6],
['var' => 'right', 'col' => 6]
],
[ // row 2
['var' => 'bottom', 'col' => 12]
],
];
public abstract array getConfigPlaceholdersByRowsExport ( ) | ||
return | array |
Returns an array where each element is a row containing informations about the placeholders. |
---|
public function getConfigPlaceholdersByRowsExport();
Returns all config placeholders element of key value pairing to pass to the Admin ANGULAR API
public abstract array getConfigPlaceholdersExport ( ) |
public function getConfigPlaceholdersExport();
Returns all config vars element of key value pairing to pass to the Admin ANGULAR API
public abstract array getConfigVarsExport ( ) |
public function getConfigVarsExport();
Returns an array of key value pairing with additional informations to pass to the API and frontend.
public abstract array getExtraVarValues ( ) |
public function getExtraVarValues();
Returns an array with additional help informations for specific field (var or cfg).
The returning array must contain a key where is the field name and a value to display, Example:
return [
'content' => 'An explain example of what this var does it where its displayed.',
];
Assuming there is a config var named content
.
public abstract array getFieldHelp ( ) | ||
return | array |
An array where the key is the cfg/var field var name and the value the helper text. |
---|
public function getFieldHelp();
Whether cache is enabled for this block or not.
public abstract boolean getIsCacheEnabled ( ) |
public function getIsCacheEnabled();
Whether this is a container element or not. Container elements usually have defined placeholders.
public abstract boolean getIsContainer ( ) |
public function getIsContainer();
Whether the dirty marker dialog is enable or not.
This can be usefull when working with blocks which does not require any input data, so therefore it does not require a dirty marked dialog.
public abstract boolean getIsDirtyDialogEnabled ( ) |
public function getIsDirtyDialogEnabled();
Returns the icon based on material icon names
public abstract string icon ( ) |
public function icon();
Get the name of the block in order to display in administration context.
public abstract void name ( ) |
public function name();
Will called when the block is saved to the cache.
public abstract void onRegister ( ) |
public function onRegister();
Will called when the block is loaded from the cache.
public abstract void onRegisterFromCache ( ) |
public function onRegisterFromCache();
This method is called whenever a block inside a placeholder is rendered.
This allows you to change the render behavior of every block inside a placeholder. An example of adding a wrapper div to the iteration:
public function placeholderRenderIteration(BlockInterface $block)
{
return '<div class="block-wrapper">'.$block->renderFrontend().'</div>';
}
This also allows you to determined whether the block should be rendered or not as the response is the content of the block inside the placholder.
public abstract string placeholderRenderIteration ( luya\cms\base\BlockInterface $block ) | ||
$block | luya\cms\base\BlockInterface |
public function placeholderRenderIteration(BlockInterface $block);
Get the output in administration context.
public abstract string renderAdmin ( ) |
public function renderAdmin();
Create a html img tag and use the preview image at {module}/resources/img/{block-name}.jpg as source.
If no image source exists, it will return false.
public abstract string|boolean renderAdminPreview ( ) | ||
return | string|boolean |
False if no preview available, otherwise the html img as string. |
---|
public function renderAdminPreview();
Get the output in the frontend context.
public abstract string renderFrontend ( ) |
public function renderFrontend();
Set the values for element cfgs with an array key value binding.
public abstract void setCfgValues ( array $values ) | ||
$values | array |
An array where key is the name of the cfg-element and value the content. |
public function setCfgValues(array $values);
Set an environment option informations to the block with key value pairing.
public abstract void setEnvOption ( $key, $value ) | ||
$key | string |
The identifier key. |
$value | mixed |
The value for the key. |
public function setEnvOption($key, $value);
Set the value from placeholders where the array key is the name of value the content of the placeholder.
public abstract void setPlaceholderValues ( array $placeholders ) | ||
$placeholders | array |
An array with placeholders where key is name and the value the content e.g. |
public function setPlaceholderValues(array $placeholders);
Set the values for element vars with an array key value binding.
public abstract void setVarValues ( array $values ) | ||
$values | array |
An array where key is the name of the var-element and value the content. |
public function setVarValues(array $values);
This method is run when the block object is initialized in frontend context.
public abstract void setup ( ) |
public function setup();