OneManyPropSvcCfg extends BasePropSvcCfg
A property service configuration for a one to many relationship.
The parent model is expected to have an array property named $arrayProperty and be bound to instances of the linked model. The linked model must contain a property with the parent id The linked model must contain a single primary key property
Use this with a OneManyPropertyService
Table of Contents
$parentIdProperty | Parent Id property name | string |
---|---|---|
$arrayProperty | Parent array property name | string |
$entityProperty | Linked model entity id property name | string |
$idProperty | Linked model property name | string |
$repo | Address repo | IRepository |
$saveFunc | Retrieve the save function f( IModel ) : ISaveFunction | Closure |
$beforeSave | List of before save functions | \Closure[] |
$afterSave | List of after save functions | \Closure[] |
$beforeSave | Before save events | \Closure[] |
$afterSave | After save events | \Closure[] |
$cache | Cache for config array | array |
$nameCache | A cache of property names | string[] |
$behavior | Behavior map | array |
$mValidate | Model validation function from INamedPropertyBehavior | Closure |
$isConstructed | Ghetto, but this is true if the end of the constructor has been reached. | bool |
$mValidateData | ||
__construct() | Create a new OneManyPropSvcCfg instance | mixed |
getPropertyName() | Retrieve the property name used to load the backing model for a property service | string |
getModelPropertyName() | Retrieve the property name used for the backing model for some property service. | string |
createConfig() | Retrieve the mfg prop svc config array | array |
createSaveFunction() | Retrieve a save function to be used with some transaction. | array |
__construct() | Constructor | mixed |
getSaveFunction() | Retrieve a save function to be used with some transaction. | array |
createSaveFunction() | Retrieve a save function to be used with some transaction. | array |
createConfig() | Retrieve the configuration array for generating model properties. | array |
beforeSave() | Called via SaveableMappingObjectFactory, and happens as part of the beforeSave event. | void |
afterSave() | Called via SaveableMappingObjectFactory, and happens as part of the afterSave event. | void |
getValidation() | Retrieve a validation callback that can be used for IModel instances. | Closure |
addValidation() | Adds an additional validation closure to the stack. | void |
addBeforeSave() | Adds an additional beforeSave closure to the stack. | void |
addAfterSave() | Adds an additional afterSave closure to the stack. | void |
getPropertyNames() | Retrieve a list of property names defined via this config | array |
getConfig() | Retrieve the configuration array used to create model instances. | array |
getEnumCfg() | array | |
removeFlagFromConfigEntry() | void | |
addFlagToConfigEntry() | mixed | |
createModelValidationClosure() | Creates the model validation closure | Closure|null |
getBehavior() | Retrieve any additional behavior for some property. | array |
addBehaviorToArray() | mixed | |
getUsedBehavior() | This is currently UNUSED. HA! | array |
processBehavior() | Process any associated behavior for some config array | array |
getFunctionList() | Create a list of functions for some behavior function | array |
getInitCallback() | Create an init callback property value for multiple functions | Closure|null |
getOnChangeCallback() | Create the on change callback | Closure|null |
getHTMLInputCallback() | Closure|null | |
getValidateCallback() | Create a validate callback for multiple functions. | Closure|null |
getGetterSetterCallback() | Create a property getter/setter callback for multiple functions. | Closure|null |
getModelGetterSetterCallback() | Create a property model setter callback for multiple functions. | Closure|null |
processEntry() | Process a config entry. | mixed |
Properties
$parentIdProperty
Parent Id property name
private
string
$parentIdProperty
$arrayProperty
Parent array property name
private
string
$arrayProperty
$entityProperty
Linked model entity id property name
private
string
$entityProperty
$idProperty
Linked model property name
private
string
$idProperty
$repo
Address repo
private
IRepository
$repo
$saveFunc
Retrieve the save function f( IModel ) : ISaveFunction
private
Closure
$saveFunc
$beforeSave
List of before save functions
private
\Closure[]
$beforeSave
$afterSave
List of after save functions
private
\Closure[]
$afterSave
$beforeSave
Before save events
private
\Closure[]
$beforeSave
= []
$afterSave
After save events
private
\Closure[]
$afterSave
= []
$cache
Cache for config array
private
array
$cache
= []
$nameCache
A cache of property names
private
string[]
$nameCache
= []
$behavior
Behavior map
private
array
$behavior
= []
$mValidate
Model validation function from INamedPropertyBehavior
private
Closure
$mValidate
= null
$isConstructed
Ghetto, but this is true if the end of the constructor has been reached.
private
bool
$isConstructed
= false
$mValidateData
private
mixed
$mValidateData
= []
Methods
__construct()
Create a new OneManyPropSvcCfg instance
public
__construct(
$repo :
IRepository
, $parentIdProperty :
string
, $arrayProperty :
string
, $linkEntityProperty :
string
, $idProperty :
string
[, $beforeSave :
Closure|null
= null ]
[, $afterSave :
Closure|null
= null ]
, ...$behavior :
INamedPropertyBehavior
)
: mixed
NOTE: There is zero point to having the behavior classes tacked on to the end of this. This property service has absolutely no way to utilize the behavior as behaviors need to be built along with the property set config when creating IPropertySet instances. The behavior argument will be removed when I get time.
Parameters
- $repo : IRepository
Linked model repository
- $parentIdProperty : string
The parent model primary key property name.
- $arrayProperty : string
The parent model property name for the array of linked models
- $linkEntityProperty : string
A linked model property that contains the parent id
- $idProperty : string
A linked model property containing the unique id of the linked model
- $beforeSave : Closure|null = null
- $afterSave : Closure|null = null
- $behavior : INamedPropertyBehavior
Property behavior modifications
Tags
Return values
mixedgetPropertyName()
Retrieve the property name used to load the backing model for a property service
public
getPropertyName(
)
: string
Return values
string —name
getModelPropertyName()
Retrieve the property name used for the backing model for some property service.
public
getModelPropertyName(
)
: string
Return values
string —name
createConfig()
Retrieve the mfg prop svc config array
protected
createConfig(
)
: array
Return values
array —config
createSaveFunction()
Retrieve a save function to be used with some transaction.
protected
createSaveFunction(
$parent :
IModel
)
: array
Parameters
- $parent : IModel
Model this provider is linked to
Tags
Return values
array —IRunnable[] Something the saves data
__construct()
Constructor
public
__construct(
...$behavior :
INamedPropertyBehavior
)
: mixed
Parameters
- $behavior : INamedPropertyBehavior
Additional property behavior NOTE: the beforeSave and afterSave property behavior methods are unlikely to work with standard IPropertyService implementations. Functioning would be based on the controlling service. All IModelPropertyProvider implementations can take advantage of beforeSave() and afterSave().
Return values
mixedgetSaveFunction()
Retrieve a save function to be used with some transaction.
public
final getSaveFunction(
$parent :
IModel
)
: array
Parameters
- $parent : IModel
Model this provider is linked to
Tags
Return values
array —IRunnable[] Something the saves data
createSaveFunction()
Retrieve a save function to be used with some transaction.
protected
createSaveFunction(
$parent :
IModel
)
: array
Parameters
- $parent : IModel
Model this provider is linked to
Tags
Return values
array —IRunnable[] Something the saves data
createConfig()
Retrieve the configuration array for generating model properties.
protected
abstract createConfig(
)
: array
Return values
arraybeforeSave()
Called via SaveableMappingObjectFactory, and happens as part of the beforeSave event.
public
final beforeSave(
$model :
IModel
)
: void
Parameters
- $model : IModel
Model being saved
Tags
afterSave()
Called via SaveableMappingObjectFactory, and happens as part of the afterSave event.
public
final afterSave(
$model :
IModel
)
: void
Parameters
- $model : IModel
Model being saved
Tags
getValidation()
Retrieve a validation callback that can be used for IModel instances.
public
final getValidation(
)
: Closure
Tags
Return values
Closure —f( IModel $model ) throws ValidationException
addValidation()
Adds an additional validation closure to the stack.
protected
final addValidation(
$f :
Closure
)
: void
Parameters
- $f : Closure
New validation function. f( IModel $model ) : void throws ValidationException
Tags
addBeforeSave()
Adds an additional beforeSave closure to the stack.
protected
final addBeforeSave(
$f :
Closure
)
: void
Parameters
- $f : Closure
New beforeSAve function. f( IModel $model ) : void
Tags
addAfterSave()
Adds an additional afterSave closure to the stack.
protected
final addAfterSave(
$f :
Closure
)
: void
Parameters
- $f : Closure
New afterSave function. f( IModel $model ) : void
Tags
getPropertyNames()
Retrieve a list of property names defined via this config
public
getPropertyNames(
)
: array
Return values
array —names
getConfig()
Retrieve the configuration array used to create model instances.
public
getConfig(
)
: array
Return values
array —config data
getEnumCfg()
protected
getEnumCfg(
$class :
string
[, $value :
mixed
= '' ]
)
: array
Parameters
- $class : string
- $value : mixed = ''
Return values
arrayremoveFlagFromConfigEntry()
protected
removeFlagFromConfigEntry(
&$entry :
array
, $flag :
string
)
: void
Parameters
- $entry : array
- $flag : string
addFlagToConfigEntry()
protected
addFlagToConfigEntry(
&$entry :
array
, $flag :
string
)
: mixed
Parameters
- $entry : array
- $flag : string
Return values
mixedcreateModelValidationClosure()
Creates the model validation closure
private
createModelValidationClosure(
$mValidate :
array
)
: Closure|null
Parameters
- $mValidate : array
Closure[] behavior closures
Return values
Closure|null —function
getBehavior()
Retrieve any additional behavior for some property.
private
getBehavior(
$property :
string
)
: array
If none is assigned, then an empty array is returned.
Parameters
- $property : string
Property name
Return values
array —INamedPropertyBehavior[] additional behavior
addBehaviorToArray()
private
addBehaviorToArray(
&$out :
mixed
, $key :
string
, $f :
Closure|null
)
: mixed
Parameters
- $out : mixed
- $key : string
- $f : Closure|null
Return values
mixedgetUsedBehavior()
This is currently UNUSED. HA!
private
getUsedBehavior(
...$behavior :
INamedPropertyBehavior
)
: array
Parameters
- $behavior : INamedPropertyBehavior
Return values
arrayprocessBehavior()
Process any associated behavior for some config array
private
processBehavior(
$config :
array
)
: array
Parameters
- $config : array
config array
Return values
array —modified array
getFunctionList()
Create a list of functions for some behavior function
private
getFunctionList(
$method :
string
, ...$behavior :
INamedPropertyBehavior
)
: array
Parameters
- $method : string
Behavior function to call.
- $behavior : INamedPropertyBehavior
Behavior objects
Return values
array —\Closure[] list of additional behavior functions
getInitCallback()
Create an init callback property value for multiple functions
private
getInitCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional init functions
Return values
Closure|null —Combined function
getOnChangeCallback()
Create the on change callback
private
getOnChangeCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional functions
Return values
Closure|null —Combined function
getHTMLInputCallback()
private
getHTMLInputCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional functions
Return values
Closure|null —Combined function
getValidateCallback()
Create a validate callback for multiple functions.
private
getValidateCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional functions
Return values
Closure|null —Combined function
getGetterSetterCallback()
Create a property getter/setter callback for multiple functions.
private
getGetterSetterCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional functions
Return values
Closure|null —Combined function
getModelGetterSetterCallback()
Create a property model setter callback for multiple functions.
private
getModelGetterSetterCallback(
$value :
Closure|null
, ...$functions :
Closure
)
: Closure|null
Parameters
- $value : Closure|null
Closure|null from property config array
- $functions : Closure
A list of additional functions
Return values
Closure|null —Combined function
processEntry()
Process a config entry.
private
processEntry(
$prop :
string
, $value :
mixed
, ...$behavior :
INamedPropertyBehavior
)
: mixed
For any callbacks attached to the config, concatenate that callback with any attached to some named property behavior.
Parameters
- $prop : string
Property name
- $value : mixed
Config entry property value
- $behavior : INamedPropertyBehavior
Behavior for this property
Return values
mixed —value