\QuickApps\Model\BehaviorSerializableBehavior

Serializable Behavior.

Allows store serializable information into table columns.

Summary

Methods
Properties
Constants
__construct()
beforeMarshal()
beforeFind()
No public properties found
No constants found
No protected methods found
$_defaultConfig
N/A
No private methods found
No private properties found
N/A

Properties

$_defaultConfig

$_defaultConfig : array

Default configuration.

Type

array

Methods

__construct()

__construct(\Cake\ORM\Table $table, array $config)

Constructor

Merges config with the default and store in the config property

Parameters

\Cake\ORM\Table $table

The table this behavior is attached to.

array $config

The config for this behavior.

beforeMarshal()

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

Triggered before data is converted into entities.

Moves multi-value POST data into its corresponding column, for instance given the following POST array:

[
    'settings:max_time' => 10,
    'settings:color' => '#005599',
    'my_column:other_option' => 'some value',
]

It becomes:

[
    'settings' => [
        'max_time' => 10,
        'color' => '#005599',
    ],
    'my_column' => [
        'other_option' => 'some value',
    ]
]

Parameters

\Cake\Event\Event $event

The event that was triggered

\ArrayObject $data

The POST data to be merged with entity

\ArrayObject $options

The options passed to the marshaller

beforeFind()

beforeFind(\Cake\Event\Event $event, \Cake\ORM\Query $query, \ArrayObject $options, boolean $primary) : void

Here we set default values for serializable columns.

This method triggers the <TableAlias>.<columnName>.defaultValues event, for example "Plugins.settings.defaultValues" for the "settings" columns of the "Plugins" table. Event listeners should catch this event and provides the desired values.

Options:

  • flatten: Flattens serialized information into plain entity properties, for example settings:some_option => value. Valid only for column that stores array values.

Parameters

\Cake\Event\Event $event

The event that was triggered

\Cake\ORM\Query $query

Query object

\ArrayObject $options

Additional options as an array

boolean $primary

Whether is find is a primary query or not