\Block\Model\TableBlocksTable

Represents "blocks" database table.

The following events related to block life cycle are triggered by this class:

  • Block..beforeSave
  • Block..afterSave
  • Block..beforeDelete
  • Block..afterDelete

Summary

Methods
Properties
Constants
implementedEvents()
initialize()
inFrontTheme()
inBackTheme()
unused()
buildRules()
validationWidget()
validationCustom()
settingsValidate()
settingsDefaultValues()
beforeSave()
afterSave()
beforeDelete()
afterDelete()
clearCache()
trigger()
eventDispatcher()
triggered()
$Roles
$Blocks
$BlockRegions
No constants found
_inTheme()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$Roles

$Roles : \User\Model\Table\RolesTable

Type

\User\Model\Table\RolesTable

$Blocks

$Blocks : \Block\Model\Table\BlocksTable

Type

\Block\Model\Table\BlocksTable

$BlockRegions

$BlockRegions : \Block\Model\Table\BlockRegionsTable

Type

\Block\Model\Table\BlockRegionsTable

Methods

implementedEvents()

implementedEvents() : array

Get the Model callbacks this table is interested in.

Returns

array

initialize()

initialize(array $config) : void

Initialize method.

Parameters

array $config

The configuration for the Table.

inFrontTheme()

inFrontTheme() : mixed

Gets a list of all blocks renderable in front-end theme.

Returns

mixed

inBackTheme()

inBackTheme() : mixed

Gets a list of all blocks renderable in front-end theme.

Returns

mixed

unused()

unused() : \Cake\Collection\CollectionInterface

Gets a list of all blocks that are NOT renderable.

Returns

\Cake\Collection\CollectionInterface

buildRules()

buildRules(\Cake\ORM\RulesChecker $rules) : \Cake\ORM\RulesChecker

Application rules.

Parameters

\Cake\ORM\RulesChecker $rules

The rule checker

Returns

\Cake\ORM\RulesChecker

validationWidget()

validationWidget(\Cake\Validation\Validator $validator) : \Cake\Validation\Validator

Default validation rules.

Parameters

\Cake\Validation\Validator $validator

The validator object

Returns

\Cake\Validation\Validator

validationCustom()

validationCustom(\Cake\Validation\Validator $validator) : \Cake\Validation\Validator

Validation rules for custom blocks.

Plugins may define their own blocks, in these cases the "body" value is optional. But blocks created by users (on the Blocks administration page) are required to have a valid "body".

Parameters

\Cake\Validation\Validator $validator

The validator object

Returns

\Cake\Validation\Validator

settingsValidate()

settingsValidate(\Cake\Event\Event $event, array $data, \ArrayObject $options) : void

Validates block settings before persisted in DB.

Parameters

\Cake\Event\Event $event

The event that was triggered

array $data

Information to be validated

\ArrayObject $options

Options given to pathEntity()

settingsDefaultValues()

settingsDefaultValues(\Cake\Event\Event $event, \Cake\ORM\Entity $block) : array

Here we set default values for block's settings (used by Widget Blocks).

Triggers the Block.<handler>.settingsDefaults event, event listeners should catch the event and return an array as key => value with default values.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Cake\ORM\Entity $block

The block where to put those values

Returns

array

beforeSave()

beforeSave(\Cake\Event\Event $event, \Block\Model\Entity\Block $block, \ArrayObject $options) : boolean

Triggers the following events:

  • Block.<handler>.beforeSave

Parameters

\Cake\Event\Event $event

The event that was triggered

\Block\Model\Entity\Block $block

The block entity being saved

\ArrayObject $options

Additional options given as an array

Returns

boolean —

False if save operation should not continue, true otherwise

afterSave()

afterSave(\Cake\Event\Event $event, \Block\Model\Entity\Block $block, \ArrayObject $options) : void

Triggers the "Block.<handler>.afterSave" hook, so plugins may do any logic their require.

All cached blocks are automatically removed.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Block\Model\Entity\Block $block

The block entity that was saved

\ArrayObject $options

Additional options given as an array

beforeDelete()

beforeDelete(\Cake\Event\Event $event, \Block\Model\Entity\Block $block, \ArrayObject $options) : boolean

Triggers the "Block.<handler>.beforeDelete" hook, so plugins may do any logic their require.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Block\Model\Entity\Block $block

The block entity being deleted

\ArrayObject $options

Additional options given as an array

Returns

boolean —

False if delete operation should not continue, true otherwise

afterDelete()

afterDelete(\Cake\Event\Event $event, \Block\Model\Entity\Block $block, \ArrayObject $options) : void

Triggers the "Block.<handler>.afterDelete" hook, so plugins may do any logic their require.

All cached blocks are automatically removed.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Block\Model\Entity\Block $block

The block entity that was deleted

\ArrayObject $options

Additional options given as an array

clearCache()

clearCache() : void

Clear blocks cache for all themes and all regions.

trigger()

trigger(array|string $eventName) : \Cake\Event\Event

Triggers the given event name. This method provides a shortcut for:

$this->trigger('EventName', $arg1, $arg2, ..., $argn);

You can provide a subject to use by passing an array as first arguments where the first element is the event name and the second one is the subject, if no subject is given $this will be used by default:

$this->trigger(['GetTime', new MySubject()], $arg_0, $arg_1, ..., $arg_n);

You can also indicate an EventDispatcher instance to use by prefixing the event name with <InstanceName>::, for instance:

$this->trigger('Blog::EventName', $arg1, $arg2, ..., $argn);

This will use the EventDispacher instance named Blog and will trigger the event EventName within that instance.

Parameters

array|string $eventName

The event name to trigger

Returns

\Cake\Event\Event —

The event object that was fired

eventDispatcher()

eventDispatcher(string $name) : \QuickApps\Event\EventDispatcher

Gets an instance of the given Event Dispatcher name.

Usage:

$this->eventDispatcher('myDispatcher')
    ->trigger('MyEventName', $argument)
    ->result;

Parameters

string $name

Name of the dispatcher to get, defaults to 'default'

Returns

\QuickApps\Event\EventDispatcher

triggered()

triggered(string|null $eventName) : integer|array

Retrieves the number of times an event was triggered, or the complete list of events that were triggered.

Parameters

string|null $eventName

The name of the event, if null returns the entire list of event that were fired

Returns

integer|array

_inTheme()

_inTheme(string $type) : array

Gets a list of all blocks renderable in the given theme type (frontend or backend).

Parameters

string $type

Possible values are 'front' or 'back'

Returns

array —

Blocks index by region name