W3cubDocs

/CakePHP 4.4

Class
SaveOptionsBuilder

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.

Namespace: Cake\ORM
Deprecated: 4.4.0 Use a normal array for options instead.
See: \Cake\Datasource\RulesChecker

Property Summary

  • $_options protected
    array<string, mixed>

    Options

  • $_table protected
    Cake\ORM\Table

    Table object.

Method Summary

Method Detail

__construct() public

__construct(Cake\ORM\Table $table, array<string, mixed> $options = [])

Constructor.

Parameters

Cake\ORM\Table $table

A table instance.

array<string, mixed> $options optional

Options to parse when instantiating.

_associated() protected

_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.

Returns

void

_checkAssociation() protected

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

Checks if an association exists.

Parameters

Cake\ORM\Table $table

Table object.

string $association

Association name.

Returns

void

Throws

RuntimeException
If no such association exists for the given table.

_normalizeAssociations() protected

_normalizeAssociations(array|string $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|string $associations

The array of included associations.

Returns

array

associated() public

associated(array|string $associated): $this

Set associated options.

Parameters

array|string $associated

String or array of associations.

Returns

$this

atomic() public

atomic(bool $atomic): $this

Sets the atomic option.

Parameters

bool $atomic

Atomic or not.

Returns

$this

checkExisting() public

checkExisting(bool $checkExisting): $this

Set check existing option.

Parameters

bool $checkExisting

Guard the properties or not.

Returns

$this

checkRules() public

checkRules(bool $checkRules): $this

Option to check the rules.

Parameters

bool $checkRules

Check the rules or not.

Returns

$this

guard() public

guard(bool $guard): $this

Set the guard option.

Parameters

bool $guard

Guard the properties or not.

Returns

$this

parseArrayOptions() public

parseArrayOptions(array<string, mixed> $array): $this

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<string, mixed> $array

Options array.

Returns

$this

Throws

InvalidArgumentException
If a given option key does not exist.

set() public

set(string $option, mixed $value): $this

Setting custom options.

Parameters

string $option

Option key.

mixed $value

Option value.

Returns

$this

toArray() public

toArray(): array<string, mixed>

Returns

array<string, mixed>

validate() public

validate(string $validate): $this

Set the validation rule set to use.

Parameters

string $validate

Name of the validation rule set to use.

Returns

$this

Property Detail

$_options protected

Options

Type

array<string, mixed>

$_table protected

Table object.

Type

Cake\ORM\Table

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.ORM.SaveOptionsBuilder.html