GenericNamedPropertyBehavior extends PropertyBehavior implements INamedPropertyBehavior
Property behavior for some property. Extend this and override methods.
Table of Contents
$name | Property name | string |
---|---|---|
$validate | Validate data closure for save() [bool is valid] = function( IProperty, [input value] ) | Closure|null |
$getter | Get value callback | Closure|null |
$setter | Set value callback | Closure|null |
$mgetter | Get value callback | Closure|null |
$msetter | Set value callback | Closure|null |
$init | Initializer callback | Closure|null |
$onChange | On Change event | Closure|null |
$htmlInput | Get html input event | Closure|null |
$isEmpty | Is empty event | Closure|null |
__construct() | Create a new PropertyBehavior instance. | mixed |
getPropertyName() | Retrieve the property name associated with this behavior. | string |
getBeforeSaveCallback() | Retrieve the before save function | Closure|null |
getAfterSaveCallback() | Retrieve the after save function | Closure|null |
getModelValidationCallback() | Retrieve the model validation callback. | Closure|null |
__construct() | Create a new PropertyBehavior instance. | mixed |
__clone() | mixed | |
getOnChangeCallback() | Retrieve the onChange callback f( IProperty, oldValue, newValue ) : void | Closure|null |
getIsEmptyCallback() | Retrieve the closure that can test empty state. | Closure|null |
getValidateCallback() | Callback used to provide additional validation for some property. | Closure |
getSetterCallback() | Callback used to set a value. | Closure |
getGetterCallback() | Callback used when retrieving a value. | Closure|null |
getModelSetterCallback() | Callback used to set a value. | Closure |
getModelGetterCallback() | Callback used when retrieving a value. | Closure|null |
getInitCallback() | Callback used for initializing some value when the model is loaded. | Closure |
getHTMLInputCallback() | Retrieve a callback that converts a property into an html form input. | Closure|null |
Properties
$name
Property name
private
string
$name
$validate
Validate data closure for save() [bool is valid] = function( IProperty, [input value] )
private
Closure|null
$validate
$getter
Get value callback
private
Closure|null
$getter
$setter
Set value callback
private
Closure|null
$setter
$mgetter
Get value callback
private
Closure|null
$mgetter
$msetter
Set value callback
private
Closure|null
$msetter
$init
Initializer callback
private
Closure|null
$init
$onChange
On Change event
private
Closure|null
$onChange
$htmlInput
Get html input event
private
Closure|null
$htmlInput
$isEmpty
Is empty event
private
Closure|null
$isEmpty
Methods
__construct()
Create a new PropertyBehavior instance.
public
__construct(
$name :
string
)
: mixed
The PropertyBehavior constructor is called with zero arguments, therefore the closures contained within are always null unless overridden.
WARNING: Possibility of shenanigans!
Closures attached to this object SHOULD reference some variable equal to $this (inside the closure), instead of accessing $this directly.
Parameters
- $name : string
Property name this behavior modifies. Pass static::class from the descending class if this is part of a generic strategy.
Return values
mixedgetPropertyName()
Retrieve the property name associated with this behavior.
public
getPropertyName(
)
: string
Return values
stringgetBeforeSaveCallback()
Retrieve the before save function
public
getBeforeSaveCallback(
)
: Closure|null
Return values
Closure|null —function
getAfterSaveCallback()
Retrieve the after save function
public
getAfterSaveCallback(
)
: Closure|null
Return values
Closure|null —function
getModelValidationCallback()
Retrieve the model validation callback.
public
getModelValidationCallback(
)
: Closure|null
f( IModel $model ) throws ValidationException
Return values
Closure|null__construct()
Create a new PropertyBehavior instance.
public
__construct(
[ $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 ]
)
: mixed
WARNING: Possibility of shenanigans!
Closures attached to this object SHOULD reference some variable equal to $this (inside the closure), instead of accessing $this directly.
Parameters
- $validate : Closure|null = null
Validate closure f( IProperty, $value ) Throw a ValidationException on error
- $init : Closure|null = null
f( value ) : mixed
- $setter : Closure|null = null
f( IProperty, value ) : mixed
- $getter : Closure|null = null
f( IProperty, value ) : mixed
- $msetter : Closure|null = null
f( IModel, IProperty, value ) : mixed
- $mgetter : Closure|null = null
f( IModel, IProperty, value ) : mixed
- $onChange : Closure|null = null
f( IProperty, oldValue, newValue ) : void
- $isEmpty : Closure|null = null
f( IProperty ) : bool
- $htmlInput : Closure|null = null
f( IModel $model, IProperty $property, string $name, string $id, string $value ) : IElement
Return values
mixed__clone()
public
__clone(
)
: mixed
Return values
mixedgetOnChangeCallback()
Retrieve the onChange callback f( IProperty, oldValue, newValue ) : void
public
getOnChangeCallback(
)
: Closure|null
Return values
Closure|nullgetIsEmptyCallback()
Retrieve the closure that can test empty state.
public
getIsEmptyCallback(
)
: Closure|null
Return values
Closure|nullgetValidateCallback()
Callback used to provide additional validation for some property.
public
getValidateCallback(
)
: Closure
This is called prior to IProperty::validate()
function( IProperty, [input value] ) : bool
Return values
Closure —callback
getSetterCallback()
Callback used to set a value.
public
getSetterCallback(
)
: Closure
This is called prior to IProperty::validate() and the return value will replace the supplied value.
f( IProperty, value ) : mixed
Return values
Closure —callback
getGetterCallback()
Callback used when retrieving a value.
public
getGetterCallback(
)
: Closure|null
Called during IProperty::getValue(). The return value will be used as the return value from getValue(); f( IProperty, value ) : mixed
Return values
Closure|nullgetModelSetterCallback()
Callback used to set a value.
public
getModelSetterCallback(
)
: Closure
This is called prior to IProperty::validate() and the return value will replace the supplied value.
f( IModel, IProperty, value ) : mixed
Return values
Closure —callback
getModelGetterCallback()
Callback used when retrieving a value.
public
getModelGetterCallback(
)
: Closure|null
Called during IProperty::getValue(). The return value will be used as the return value from getValue(); f( IModel, IProperty, value ) : mixed
Return values
Closure|nullgetInitCallback()
Callback used for initializing some value when the model is loaded.
public
getInitCallback(
)
: Closure
The return value will be used as the default value for the property. f( $value ) : mixed
Return values
Closure —callback
getHTMLInputCallback()
Retrieve a callback that converts a property into an html form input.
public
getHTMLInputCallback(
)
: Closure|null
f( IModel $model, IProperty $property, string $name, string $id, $value ) : IElement