PHP Class Tools\Model\Behavior\StringBehavior

Note that most string modification should be done once, on save. Prevent using output modification if possible as it is done on every fetch. Tip: If you have other behaviors that might modify the array data prior to saving, better use a higher priority: $this->addBehavior('Tools.String', array('priority' => 11, ...)); So that it is run last. Usage: See docs
Author: Mark Scherer
Inheritance: extends Cake\ORM\Behavior
Show file Open project: dereuromark/cakephp-tools

Protected Properties

Property Type Description
$_defaultConfig array TODO: json input/ouput directly, clean

Public Methods

Method Description
_process ( string $val, array $map ) : string Process val via map
beforeFind ( Cake\Event\Event $event, Query $query ) : void Decode the fields on after find
beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void Saves all fields that do not belong to the current Model into 'with' helper model.
initialize ( array $config = [] ) : void
processItems ( Cake\ORM\Entity $entity, string $type = 'input' ) : void Decodes the fields of an array/entity (if the value itself was encoded)

Method Details

_process() public method

Process val via map
public _process ( string $val, array $map ) : string
$val string
$map array
return string

beforeFind() public method

Decode the fields on after find
public beforeFind ( Cake\Event\Event $event, Query $query ) : void
$event Cake\Event\Event
$query Cake\ORM\Query
return void

beforeSave() public method

Saves all fields that do not belong to the current Model into 'with' helper model.
public beforeSave ( Cake\Event\Event $event, Cake\ORM\Entity $entity, ArrayObject $options ) : void
$event Cake\Event\Event
$entity Cake\ORM\Entity
$options ArrayObject
return void

initialize() public method

public initialize ( array $config = [] ) : void
$config array
return void

processItems() public method

Decodes the fields of an array/entity (if the value itself was encoded)
public processItems ( Cake\ORM\Entity $entity, string $type = 'input' ) : void
$entity Cake\ORM\Entity
$type string Type (input/output)
return void

Property Details

$_defaultConfig protected property

TODO: json input/ouput directly, clean
protected array $_defaultConfig
return array