You are here

public function ContextDefinition::toArray in Rules 8.3

Exports the definition as an array.

Return value

array An array with values for all definition keys.

Overrides ContextDefinitionInterface::toArray

File

src/Context/ContextDefinition.php, line 114

Class

ContextDefinition
Extends the core context definition class with useful methods.

Namespace

Drupal\rules\Context

Code

public function toArray() {
  $values = [];
  $defaults = get_class_vars(__CLASS__);
  foreach (static::$nameMap as $key => $property_name) {

    // Only export values for non-default properties.
    if ($this->{$property_name} !== $defaults[$property_name]) {
      $values[$key] = $this->{$property_name};
    }
  }
  return $values;
}