GenericPropSvcCfg extends GenericPropertyConfig implements IPropertySvcConfig
A generic property service configuration object.
Contains information about how a property service functions.
This is a way to inline basic configurations without creating more classes.
Table of Contents
$propertyName | Id/link property name | string |
---|---|---|
$modelPropertyName | Model property name containing the generated model, etc. | string |
$config | Configuration array | array |
$propNames | Property names | array |
$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 | ||
$beforeSave | Before save events | \Closure[] |
$afterSave | After save events | \Closure[] |
__construct() | Create a new GenericPropertyConfig 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 |
getSaveFunction() | Retrieve a save function to be used with some transaction. | IRunnable |
__construct() | Constructor | mixed |
createConfig() | Retrieve the configuration array for generating model properties. | array |
getPropertyNames() | Retrieve a list of property names defined via this config | 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 |
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
$propertyName
Id/link property name
private
string
$propertyName
$modelPropertyName
Model property name containing the generated model, etc.
private
string
$modelPropertyName
$config
Configuration array
private
array
$config
$propNames
Property names
private
array
$propNames
= []
$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
= []
$beforeSave
Before save events
private
\Closure[]
$beforeSave
= []
$afterSave
After save events
private
\Closure[]
$afterSave
= []
Methods
__construct()
Create a new GenericPropertyConfig instance
public
__construct(
$propertyName :
string
, $modelPropertyName :
string
[, $config :
array
= [] ]
)
: mixed
Parameters
- $propertyName : string
Property name containing the id of the model to load
- $modelPropertyName : string
The property name containing the model
- $config : array = []
Config array
Return values
mixedgetPropertyName()
Retrieve the property name used to load the backing model for a property service.
public
getPropertyName(
)
: string
In an alternate configuration, this property can be used as the backing array of model property name;
Return values
string —name
getModelPropertyName()
Retrieve the property name used for the backing model for some property service.
public
getModelPropertyName(
)
: string
In an alternate configuration, this function may return an empty string.
Return values
string —name
getSaveFunction()
Retrieve a save function to be used with some transaction.
public
getSaveFunction(
$parent :
IModel
)
: IRunnable
Parameters
- $parent : IModel
Model this provider is linked to
Tags
Return values
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
mixedcreateConfig()
Retrieve the configuration array for generating model properties.
protected
abstract createConfig(
)
: array
Return values
arraygetPropertyNames()
Retrieve a list of property names defined via this config
public
getPropertyNames(
)
: array
Return values
array —names
beforeSave()
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
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