Fr3nch13/CakePHP Utilities

SaveOptionsBuilder extends ArrayObject
in package
uses AssociationsNormalizerTrait

OOP style Save Option Builder.

Use a normal array for options instead.

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.

Tags
see
RulesChecker

Table of Contents

Properties

$_options  : array<string, mixed>
Options
$_table  : Table
Table object.

Methods

__construct()  : mixed
Constructor.
associated()  : $this
Set associated options.
atomic()  : $this
Sets the atomic option.
checkExisting()  : $this
Set check existing option.
checkRules()  : $this
Option to check the rules.
guard()  : $this
Set the guard option.
parseArrayOptions()  : $this
Takes an options array and populates the option object with the data.
set()  : $this
Setting custom options.
toArray()  : array<string, mixed>
validate()  : $this
Set the validation rule set to use.
_associated()  : void
Checks that the associations exists recursively.
_checkAssociation()  : void
Checks if an association exists.
_normalizeAssociations()  : array<string|int, mixed>
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

Properties

Methods

__construct()

Constructor.

public __construct(Table $table[, array<string, mixed> $options = [] ]) : mixed
Parameters
$table : Table

A table instance.

$options : array<string, mixed> = []

Options to parse when instantiating.

associated()

Set associated options.

public associated(array<string|int, mixed>|string $associated) : $this
Parameters
$associated : array<string|int, mixed>|string

String or array of associations.

Return values
$this

atomic()

Sets the atomic option.

public atomic(bool $atomic) : $this
Parameters
$atomic : bool

Atomic or not.

Return values
$this

checkExisting()

Set check existing option.

public checkExisting(bool $checkExisting) : $this
Parameters
$checkExisting : bool

Guard the properties or not.

Return values
$this

checkRules()

Option to check the rules.

public checkRules(bool $checkRules) : $this
Parameters
$checkRules : bool

Check the rules or not.

Return values
$this

guard()

Set the guard option.

public guard(bool $guard) : $this
Parameters
$guard : bool

Guard the properties or not.

Return values
$this

parseArrayOptions()

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

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

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

Parameters
$array : array<string, mixed>

Options array.

Tags
throws
InvalidArgumentException

If a given option key does not exist.

Return values
$this

set()

Setting custom options.

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

Option key.

$value : mixed

Option value.

Return values
$this

toArray()

public toArray() : array<string, mixed>
Return values
array<string, mixed>

validate()

Set the validation rule set to use.

public validate(string $validate) : $this
Parameters
$validate : string

Name of the validation rule set to use.

Return values
$this

_associated()

Checks that the associations exists recursively.

protected _associated(Table $table, array<string|int, mixed> $associations) : void
Parameters
$table : Table

Table object.

$associations : array<string|int, mixed>

An associations array.

_checkAssociation()

Checks if an association exists.

protected _checkAssociation(Table $table, string $association) : void
Parameters
$table : Table

Table object.

$association : string

Association name.

Tags
throws
RuntimeException

If no such association exists for the given table.

_normalizeAssociations()

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

protected _normalizeAssociations(array<string|int, mixed>|string $associations) : array<string|int, mixed>
Parameters
$associations : array<string|int, mixed>|string

The array of included associations.

Return values
array<string|int, mixed>

An array having dot notation transformed into nested arrays


        
On this page

Search results