Setting
in package
Setting class
This class maps the
Table of Contents
Properties
- $choices : array<string|int, string>
- A list of choices. This list will be offered as a dropdown menu values.
- $field : string
- $id : string
- $key : string
- $lastError : string
- $object : string
- $regExp : string
- $handler : array<string|int, string>
- $method : string
- $property : string
Methods
- __construct() : mixed
- fromXml() : self
- Initializes a new instance of Setting class from a XML element
- get() : string
- set() : bool
- callSetMethod() : bool
- getObjectProperty() : string
- getUnderlyingObject() : object
- hasKnownObjectProperty() : bool
- hasValidFormat() : bool
- setObjectProperty() : void
Properties
$choices
A list of choices. This list will be offered as a dropdown menu values.
public
array<string|int, string>
$choices
= []
$field
public
string
$field
= ""
The kind of field to use (e.g. "text", "validationText")
$id
public
string
$id
The setting unique identifier
$key
public
string
$key
= ""
The setting unique key for rendering layer
This identified is used to populate id
and name
attributes of
the form control. They also allow to find language label to print
the name of the setting in HTML form.
$lastError
public
string
$lastError
= ""
If set, contains an error message
$object
public
string
$object
= ""
The name of the object this property belongs to.
This is mainly used for get/set variables.
Tags
$regExp
public
string
$regExp
= ""
If set, a regexp to validate the setting format
$handler
private
array<string|int, string>
$handler
= []
The custom PHP code to run to get or set the property.
Array valid keys are "get" and "set". It is acceptable to only use one, or to use both.
This requires the use of eval
and makes methods usage difficult to
track. As such, it is now recommended to add a method to your model
object, and write that method name in $method.
Tags
$method
private
string
$method
= ""
The name of the method to call in the object when the setting is set.
When left blank, it uses $handler, or if blank too, $property.
$property
private
string
$property
= ""
The name of the property in the object
Methods
__construct()
public
__construct(string $id) : mixed
Parameters
- $id : string
fromXml()
Initializes a new instance of Setting class from a XML element
public
static fromXml(SimpleXMLElement $xml) : self
Parameters
- $xml : SimpleXMLElement
Return values
selfget()
public
get() : string
Return values
stringset()
public
set(string $value) : bool
Parameters
- $value : string
Return values
boolcallSetMethod()
private
callSetMethod(string $value) : bool
Parameters
- $value : string
Return values
boolgetObjectProperty()
private
getObjectProperty() : string
Return values
stringgetUnderlyingObject()
private
getUnderlyingObject() : object
Tags
Return values
objecthasKnownObjectProperty()
private
hasKnownObjectProperty() : bool
Return values
boolhasValidFormat()
private
hasValidFormat(string $value) : bool
Parameters
- $value : string
Return values
boolsetObjectProperty()
private
setObjectProperty(string $value) : void
Parameters
- $value : string