Zed. The source code to build a world.

Setting
in package

Setting class

This class maps the XML block, from our settings XML format

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
todo

Create a targets property in Settings, then use $settings->targets[$this->object]

$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
deprecated

Create a method to your target object and use $this->method

$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
self

get()

public get() : string
Return values
string

set()

public set(string $value) : bool
Parameters
$value : string
Return values
bool

callSetMethod()

private callSetMethod(string $value) : bool
Parameters
$value : string
Return values
bool

getObjectProperty()

private getObjectProperty() : string
Return values
string

getUnderlyingObject()

private getUnderlyingObject() : object
Tags
todo

Consume $this->object from the engine targets, not from the globals

Return values
object

hasKnownObjectProperty()

private hasKnownObjectProperty() : bool
Return values
bool

hasValidFormat()

private hasValidFormat(string $value) : bool
Parameters
$value : string
Return values
bool

setObjectProperty()

private setObjectProperty(string $value) : void
Parameters
$value : string

        
On this page

Search results