System\Traits\PropertyContainer

Source: ~/modules/system/traits/PropertyContainer.php

Property container trait

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

Protected properties

protected array $properties

Contains the object property values.

Public methods

public void defineProperties()

Defines the properties used by this class. This method should be used as an override in the extended class.

public array getProperties()

Returns all properties.

public array getPropertyOptions(string $property)

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

Parameters
  • string $property - Specifies the property name

public string property(string $name, string $default=NULL)

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

Parameters
  • string $name - The property name to look for.
  • string $default - A default value to return if no name is found.

public void setProperties(array $properties)

Sets multiple properties.

Parameters
  • array $properties

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

Sets a property value

Parameters
  • string $name
  • mixed $value

public array validateProperties(array $properties)

Validates the properties against the defined properties of the class. This method also sets default properties.

Parameters
  • array $properties - The supplied property values.