You are here

protected function Billboard::getOptionsByCustomProperty in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x modules/charts_billboard/src/Plugin/chart/Library/Billboard.php \Drupal\charts_billboard\Plugin\chart\Library\Billboard::getOptionsByCustomProperty()

Get the options by custom property.

Parameters

array $element: The element.

string $type: The chart type.

Return value

array The return options.

1 call to Billboard::getOptionsByCustomProperty()
Billboard::getOptionsByType in modules/charts_billboard/src/Plugin/chart/Library/Billboard.php
Get options.

File

modules/charts_billboard/src/Plugin/chart/Library/Billboard.php, line 116

Class

Billboard
Define a concrete class for a Chart.

Namespace

Drupal\charts_billboard\Plugin\chart\Library

Code

protected function getOptionsByCustomProperty(array $element, $type) {
  $options = [];
  $properties = Element::properties($element);

  // Remove properties which are not related to this chart type.
  $properties = array_filter($properties, function ($property) use ($type) {
    $query = '#chart_' . $type . '_';
    return substr($property, 0, strlen($query)) === $query;
  });
  foreach ($properties as $property) {
    $query = '#chart_' . $type . '_';
    $option_key = substr($property, strlen($query), strlen($property));
    $options[$option_key] = $element[$property];
  }
  return $options;
}