\Cake\ORMSaveOptionsBuilder

OOP style Save Option Builder.

This allows you to build options to save entities in a OOP style and helps you to avoid mistakes by validating the options as you build them.

Summary

Methods
Properties
Constants
__construct()
parseArrayOptions()
associated()
guard()
validate()
checkExisting()
checkRules()
atomic()
toArray()
set()
No public properties found
No constants found
_normalizeAssociations()
_associated()
_checkAssociation()
$_options
$_table
N/A
No private methods found
No private properties found
N/A

Properties

$_options

$_options : array

Options

Type

array

Methods

__construct()

__construct(\Cake\ORM\Table  $table, array  $options = array()) 

Constructor.

Parameters

\Cake\ORM\Table $table

A table instance.

array $options

Options to parse when instantiating.

parseArrayOptions()

parseArrayOptions(array  $array) : \Cake\ORM\SaveOptionsBuilder

Takes an options array and populates the option object with the data.

This can be used to turn an options array into the object.

Parameters

array $array

Options array.

Throws

\InvalidArgumentException

If a given option key does not exist.

Returns

\Cake\ORM\SaveOptionsBuilder

associated()

associated(string|array  $associated) : \Cake\ORM\SaveOptionsBuilder

Set associated options.

Parameters

string|array $associated

String or array of associations.

Returns

\Cake\ORM\SaveOptionsBuilder

guard()

guard(boolean  $guard) : \Cake\ORM\SaveOptionsBuilder

Set the guard option.

Parameters

boolean $guard

Guard the properties or not.

Returns

\Cake\ORM\SaveOptionsBuilder

validate()

validate(string  $validate) : \Cake\ORM\SaveOptionsBuilder

Set the validation rule set to use.

Parameters

string $validate

Name of the validation rule set to use.

Returns

\Cake\ORM\SaveOptionsBuilder

checkExisting()

checkExisting(boolean  $checkExisting) : \Cake\ORM\SaveOptionsBuilder

Set check existing option.

Parameters

boolean $checkExisting

Guard the properties or not.

Returns

\Cake\ORM\SaveOptionsBuilder

checkRules()

checkRules(boolean  $checkRules) : \Cake\ORM\SaveOptionsBuilder

Option to check the rules.

Parameters

boolean $checkRules

Check the rules or not.

Returns

\Cake\ORM\SaveOptionsBuilder

atomic()

atomic(boolean  $atomic) : \Cake\ORM\SaveOptionsBuilder

Sets the atomic option.

Parameters

boolean $atomic

Atomic or not.

Returns

\Cake\ORM\SaveOptionsBuilder

toArray()

toArray() : array

Returns

array

set()

set(string  $option, mixed  $value) : \Cake\ORM\SaveOptionsBuilder

Setting custom options.

Parameters

string $option

Option key.

mixed $value

Option value.

Returns

\Cake\ORM\SaveOptionsBuilder

_normalizeAssociations()

_normalizeAssociations(array  $associations) : array

Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines

Parameters

array $associations

The array of included associations.

Returns

array —

An array having dot notation transformed into nested arrays

_associated()

_associated(\Cake\ORM\Table  $table, array  $associations) : void

Checks that the associations exists recursively.

Parameters

\Cake\ORM\Table $table

Table object.

array $associations

An associations array.

_checkAssociation()

_checkAssociation(\Cake\ORM\Table  $table, string  $association) : void

Checks if an association exists.

Parameters

\Cake\ORM\Table $table

Table object.

string $association

Association name.

Throws

\RuntimeException

If no such association exists for the given table.