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.
Method Summary
- 
          __construct() publicConstructor. 
- 
          _associated() protectedChecks that the associations exists recursively. 
- 
          _checkAssociation() protectedChecks if an association exists. 
- 
          _normalizeAssociations() protectedReturns 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 
- 
          associated() publicSet associated options. 
- 
          atomic() publicSets the atomic option. 
- 
          checkExisting() publicSet check existing option. 
- 
          checkRules() publicOption to check the rules. 
- 
          guard() publicSet the guard option. 
- 
          parseArrayOptions() publicTakes an options array and populates the option object with the data. 
- 
          set() publicSetting custom options. 
- 
          toArray() public
- 
          validate() publicSet the validation rule set to use. 
Method Detail
__construct() ¶ public
__construct(Cake\ORM\Table $table, array $options = [])Constructor.
Parameters
- 
                Cake\ORM\Table$table
- A table instance. 
- 
                array$options optional
- Options to parse when instantiating. 
_associated() ¶ protected
_associated(Cake\ORM\Table $table, array $associations): voidChecks 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): voidChecks if an association exists.
Parameters
- 
                Cake\ORM\Table$table
- Table object. 
- 
                string$association
- Association name. 
Returns
voidThrows
RuntimeExceptionIf no such association exists for the given table.
_normalizeAssociations() ¶ protected
_normalizeAssociations(array $associations): arrayReturns 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
arrayAn array having dot notation transformed into nested arrays
associated() ¶ public
associated(string|array $associated): Cake\ORM\SaveOptionsBuilderSet associated options.
Parameters
- 
                string|array$associated
- String or array of associations. 
Returns
Cake\ORM\SaveOptionsBuilderatomic() ¶ public
atomic(bool $atomic): Cake\ORM\SaveOptionsBuilderSets the atomic option.
Parameters
- 
                bool$atomic
- Atomic or not. 
Returns
Cake\ORM\SaveOptionsBuildercheckExisting() ¶ public
checkExisting(bool $checkExisting): Cake\ORM\SaveOptionsBuilderSet check existing option.
Parameters
- 
                bool$checkExisting
- Guard the properties or not. 
Returns
Cake\ORM\SaveOptionsBuildercheckRules() ¶ public
checkRules(bool $checkRules): Cake\ORM\SaveOptionsBuilderOption to check the rules.
Parameters
- 
                bool$checkRules
- Check the rules or not. 
Returns
Cake\ORM\SaveOptionsBuilderguard() ¶ public
guard(bool $guard): Cake\ORM\SaveOptionsBuilderSet the guard option.
Parameters
- 
                bool$guard
- Guard the properties or not. 
Returns
Cake\ORM\SaveOptionsBuilderparseArrayOptions() ¶ public
parseArrayOptions(array $array): Cake\ORM\SaveOptionsBuilderTakes 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. 
Returns
Cake\ORM\SaveOptionsBuilderThrows
InvalidArgumentExceptionIf a given option key does not exist.
set() ¶ public
set(string $option, mixed $value): Cake\ORM\SaveOptionsBuilderSetting custom options.
Parameters
- 
                string$option
- Option key. 
- 
                mixed$value
- Option value. 
Returns
Cake\ORM\SaveOptionsBuildervalidate() ¶ public
validate(string $validate): Cake\ORM\SaveOptionsBuilderSet the validation rule set to use.
Parameters
- 
                string$validate
- Name of the validation rule set to use. 
Returns
Cake\ORM\SaveOptionsBuilder