PHP Class Tools\Model\Behavior\JsonableBehavior

This is a port of the Serializeable behavior by Matsimitsu (http://www.matsimitsu.nl) Modified by Mark Scherer (http://www.dereuromark.de) Supports different input/output formats: - "list" is useful as some kind of pseudo enums or simple lists - "params" is useful for multiple key/value pairs - can be used to create dynamic forms (and tables) Also automatically cleans lists and works with custom separators etc Tip: If you have other behaviors that might modify the array data prior to saving, better use a higher priority: $this->addBehavior('Tools.Jsonable', ['priority' => 11, ...]); So that it is run last. Usage: See docs
Author: PJ Hile (http://www.pjhile.com)
Author: Mark Scherer
Inheritance: extends Cake\ORM\Behavior
Afficher le fichier Open project: dereuromark/cakephp-tools

Méthodes publiques

Свойство Type Description
$decoded string | false | null

Protected Properties

Свойство Type Description
$_defaultConfig array TODO: json input/ouput directly, clean

Méthodes publiques

Méthode Description
_decode ( array | null $val ) : array | null | false Fields are absolutely necessary to function properly!
_encode ( array | string $val ) : string | null
_fromList ( string $val ) : array
_fromParam ( string $val ) : array
_toList ( array $val ) : string array() => value1|value2|value3|.
_toParam ( array $val ) : string array() => param1:value1|param2:value2|.
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.
decodeItems ( Cake\ORM\Entity $entity ) : void Decodes the fields of an array/entity (if the value itself was encoded)
initialize ( array $config = [] ) : void
isEncoded ( string $str ) : boolean Checks if string is encoded array/object

Méthodes protégées

Méthode Description
_getMappedFields ( ) : array

Method Details

_decode() public méthode

Fields are absolutely necessary to function properly!
public _decode ( array | null $val ) : array | null | false
$val array | null
Résultat array | null | false

_encode() public méthode

public _encode ( array | string $val ) : string | null
$val array | string
Résultat string | null

_fromList() public méthode

public _fromList ( string $val ) : array
$val string
Résultat array

_fromParam() public méthode

public _fromParam ( string $val ) : array
$val string
Résultat array

_getMappedFields() protected méthode

protected _getMappedFields ( ) : array
Résultat array

_toList() public méthode

..
public _toList ( array $val ) : string
$val array
Résultat string

_toParam() public méthode

..
public _toParam ( array $val ) : string
$val array
Résultat string

beforeFind() public méthode

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

beforeSave() public méthode

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
Résultat void

decodeItems() public méthode

Decodes the fields of an array/entity (if the value itself was encoded)
public decodeItems ( Cake\ORM\Entity $entity ) : void
$entity Cake\ORM\Entity
Résultat void

initialize() public méthode

public initialize ( array $config = [] ) : void
$config array
Résultat void

isEncoded() public méthode

Checks if string is encoded array/object
public isEncoded ( string $str ) : boolean
$str string String to check
Résultat boolean

Property Details

$_defaultConfig protected_oe property

TODO: json input/ouput directly, clean
protected array $_defaultConfig
Résultat array

$decoded public_oe property

public string|false|null $decoded
Résultat string | false | null