OneManyPropertySaveFunction implements ISaveFunction
WARNING: It is currently possible for child service providers to leave orphaned rows when deleting. This seems to only happen with relationships nested > 2 levels.
Table of Contents
$parent | ||
---|---|---|
$repo | ||
$parentModelName | ||
$parentPropName | ||
$modelIdPropName | ||
$beforeSave | ||
$afterSave | ||
__construct() | Create a new save function. | mixed |
getSaveFunction() | Retrieve a list of IRunnable that contain code for saving things. | array |
Properties
$parent
private
mixed
$parent
$repo
private
mixed
$repo
$parentModelName
private
mixed
$parentModelName
$parentPropName
private
mixed
$parentPropName
$modelIdPropName
private
mixed
$modelIdPropName
$beforeSave
private
mixed
$beforeSave
$afterSave
private
mixed
$afterSave
Methods
__construct()
Create a new save function.
public
__construct(
$parent :
IModel
, $repo :
IRepository
, $parentModelName :
string
, $parentPropName :
string
, $modelIdPropName :
string
[, $beforeSave :
Closure|null
= null ]
[, $afterSave :
Closure|null
= null ]
)
: mixed
ie: Say you want to link many addresses to a single customer model.
new OneManyPropertySaveFunction( customer_model, address_repo, 'address', 'link_entity', 'id' );
customer_model is the customer IModel instance address_repo is the IRepository instance for saving IAddress instances 'address' is the array property name attached to the customer_model containing the IAddress instances 'link_entity' is an integer property attached to the address model that contains the customer id 'id' is an integer property and primary key for the address model
Parameters
- $parent : IModel
The parent model where many models are attached.
- $repo : IRepository
The repo for saving the ATTACHED models.
- $parentModelName : string
The parent property name of the array containing the linked models
- $parentPropName : string
The linked model property name that contains the id of the parent model
- $modelIdPropName : string
The linked model id property name
- $beforeSave : Closure|null = null
- $afterSave : Closure|null = null
Return values
mixedgetSaveFunction()
Retrieve a list of IRunnable that contain code for saving things.
public
getSaveFunction(
)
: array