PropertyContainer

Property container trait

 trait System\Traits\PropertyContainer

Adds properties and methods for classes that could define properties, like components or report widgets.

Properties

protected $properties : array

Contains the object property values.

Methods

public defineProperties () : array

Defines the properties used by this class.

This method should be overriden in your extended class and return an array of properties that your class uses, with the keys of the array being the name of the properties, and the values being an array of property parameters.

Example: return [ 'propertyName' => [ 'title' => 'Property name', 'description' => 'Property description', 'default' => 'Default value' ], ];

Returns
array

public getProperties () : array

Returns all properties.

Returns
array

public getPropertyOptions (string $property) : array

Returns options for multi-option properties (drop-downs, etc.)

Parameters
Property Description
$property
string

Specifies the property name

Returns
array

Return an array of option values and descriptions

public property (string $name, string $default = null) : mixed

Returns a defined property value or default if one is not set.

Parameters
Property Description
$name
string

The property name to look for.

$default
string

A default value to return if no name is found.

Returns
mixed

The property value or the default specified.

public setProperties (array $properties) : void

Sets multiple properties.

Parameters
Property Description
$properties
array
Returns
void

public setProperty (string $name, mixed $value) : void

Sets a property value

Parameters
Property Description
$name
string
$value
mixed
Returns
void

public validateProperties (array $properties) : array

Validates the properties against the defined properties of the class.

This method also sets default properties.

Parameters
Property Description
$properties
array

The supplied property values.

Returns
array

The validated property set, with defaults applied.

Used by

Class Description
Status

System status report widget.

ReportWidgetBase

Report Widget base class Report widgets are used inside the ReportContainer.

Welcome

User welcome report widget.

ComponentBase

Component base class

Resources

Resources component

SoftComponent
UnknownComponent
ViewBag

The view bag stores custom template properties.

ActiveTheme

Active theme report widget.

Copyright © 2024 Winter CMS