PHP Класс 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
Автор: PJ Hile (http://www.pjhile.com)
Автор: Mark Scherer
Наследование: extends Cake\ORM\Behavior
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$decoded string | false | null

Защищенные свойства (Protected)

Свойство Тип Описание
$_defaultConfig array TODO: json input/ouput directly, clean

Открытые методы

Метод Описание
_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

Защищенные методы

Метод Описание
_getMappedFields ( ) : array

Описание методов

_decode() публичный Метод

Fields are absolutely necessary to function properly!
public _decode ( array | null $val ) : array | null | false
$val array | null
Результат array | null | false

_encode() публичный Метод

public _encode ( array | string $val ) : string | null
$val array | string
Результат string | null

_fromList() публичный Метод

public _fromList ( string $val ) : array
$val string
Результат array

_fromParam() публичный Метод

public _fromParam ( string $val ) : array
$val string
Результат array

_getMappedFields() защищенный Метод

protected _getMappedFields ( ) : array
Результат array

_toList() публичный Метод

..
public _toList ( array $val ) : string
$val array
Результат string

_toParam() публичный Метод

..
public _toParam ( array $val ) : string
$val array
Результат string

beforeFind() публичный Метод

Decode the fields on after find
public beforeFind ( Cake\Event\Event $event, Query $query ) : void
$event Cake\Event\Event
$query Cake\ORM\Query
Результат void

beforeSave() публичный Метод

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
Результат void

decodeItems() публичный Метод

Decodes the fields of an array/entity (if the value itself was encoded)
public decodeItems ( Cake\ORM\Entity $entity ) : void
$entity Cake\ORM\Entity
Результат void

initialize() публичный Метод

public initialize ( array $config = [] ) : void
$config array
Результат void

isEncoded() публичный Метод

Checks if string is encoded array/object
public isEncoded ( string $str ) : boolean
$str string String to check
Результат boolean

Описание свойств

$_defaultConfig защищенное свойство

TODO: json input/ouput directly, clean
protected array $_defaultConfig
Результат array

$decoded публичное свойство

public string|false|null $decoded
Результат string | false | null