BasePropertyBuilderConfigMapper extends DefaultPropertyConfig implements IConfigMapper
Maps a configuration array to a list of properties.
The configuration array is as follows:
[ 'property_name' => [ //..This should be a constant from the property set interface for whatever model is being used PropertyFactory::TYPE => IPropertyType::[constant], PropertyFactory::FLAGS => [IPropertyFlags::[constant], ...], PropertyFactory::CLASS => '\namespace\classname', //(Required for TENUM,TSET and TMONEY types) PropertyFactory::MIN => 0, PropertyFactory::MAX => 100, PropertyFactory::PREPARE => function( $value, IModel $model) }, PropertyFactory::VALIDATE => function( IProperty $prop, $value ) }, PropertyFactory::PATTERN => '/[a-z]+/', //Some pattern to use as validation ] ];
Table of Contents
$pbIoc | PropertyBuilder instance factory | IPropertyBuilderIoC |
---|---|---|
$pIoc | Property factory | IPropertyIoC |
$propertyTypes | A map of string => IPropertyType | array |
$getPropertyFlags | Retrieve a new propertyFlags instance | Closure |
__construct() | Create a new PropertyFactory using some configuration array | mixed |
map() | Take a config array and convert it to a list of IProperty instances. | array |
createPropertyBehavior() | Create a new PropertyBehavior instance. | IPropertyBehavior |
createPropertyFlags() | IPropertyFlags | |
setCustomProperty() | Sets the builder property value based on the array key. | mixed |
createProperty() | IProperty | |
createBuilder() | IPropertyBuilder | |
setProperty() | Sets the builder property value based on the array key | mixed |
Properties
$pbIoc
PropertyBuilder instance factory
private
IPropertyBuilderIoC
$pbIoc
$pIoc
Property factory
private
IPropertyIoC
$pIoc
$propertyTypes
A map of string => IPropertyType
private
array
$propertyTypes
$getPropertyFlags
Retrieve a new propertyFlags instance
private
Closure
$getPropertyFlags
Methods
__construct()
Create a new PropertyFactory using some configuration array
public
__construct(
$pbIoc :
IPropertyBuilderIoC
, $pIoc :
IPropertyIoC
[, $getPropertyFlags :
Closure|null
= null ]
)
: mixed
Parameters
- $pbIoc : IPropertyBuilderIoC
- $pIoc : IPropertyIoC
- $getPropertyFlags : Closure|null = null
f() : IPropertyFlags - Retrieve a new property flags instance for use
Return values
mixedmap()
Take a config array and convert it to a list of IProperty instances.
public
map(
$config :
array
)
: array
If anything is wrong, exceptions get thrown.
Parameters
- $config : array
Tags
Return values
array —IProperty[] list of properties defined in $config
createPropertyBehavior()
Create a new PropertyBehavior instance.
protected
createPropertyBehavior(
[ $validate :
Closure|null
= null ]
[, $init :
Closure|null
= null ]
[, $setter :
Closure|null
= null ]
[, $getter :
Closure|null
= null ]
[, $msetter :
Closure|null
= null ]
[, $mgetter :
Closure|null
= null ]
[, $onChange :
Closure|null
= null ]
[, $isEmpty :
Closure|null
= null ]
[, $htmlInput :
Closure|null
= null ]
)
: IPropertyBehavior
Parameters
- $validate : Closure|null = null
Validate closure f( IProperty, $value ) Throw a ValidationException on error
- $init : Closure|null = null
- $setter : Closure|null = null
- $getter : Closure|null = null
- $msetter : Closure|null = null
- $mgetter : Closure|null = null
- $onChange : Closure|null = null
- $isEmpty : Closure|null = null
- $htmlInput : Closure|null = null
Return values
IPropertyBehaviorcreatePropertyFlags()
protected
createPropertyFlags(
$values :
mixed
)
: IPropertyFlags
Parameters
- $values : mixed
Return values
IPropertyFlagssetCustomProperty()
Sets the builder property value based on the array key.
protected
setCustomProperty(
$b :
PropertyBuilder
, $name :
string
, $k :
string
, $v :
string
)
: mixed
This function intentionally does nothing. Override this to handle some custom property type.
Parameters
- $b : PropertyBuilder
Builder instance
- $name : string
Property Name
- $k : string
Property Attribute Name
- $v : string
Property Attribute Value
Tags
Return values
mixedcreateProperty()
private
createProperty(
$builder :
IPropertyBuilder
)
: IProperty
Parameters
- $builder : IPropertyBuilder
Return values
IPropertycreateBuilder()
private
createBuilder(
$name :
string
, $data :
array
)
: IPropertyBuilder
Parameters
- $name : string
- $data : array
Return values
IPropertyBuildersetProperty()
Sets the builder property value based on the array key
private
setProperty(
$b :
PropertyBuilder
, $name :
string
, $k :
string
, $v :
string
)
: mixed
Parameters
- $b : PropertyBuilder
Builder instance
- $name : string
Property Name
- $k : string
Property Attribute Name
- $v : string
Property Attribute Value