Custom views field handler + multiple values (d8)

Hello,

i have created a custom views field handler to build & render a specific value in a view. My class extends the Numeric class.

In the “render” function of my class, I can build my data and return it. But, my data have several values, and the “return” function return only 1 value.

  public function render(ResultRow $values) {
  
	$datas_json = $values->_entity->get('field_datas')->value;
	$datas = json_decode($datas_json);
    $metric_name = 'metric';
	$metric_values = $datas->$metric_name;

    $results = array();
    foreach ($metric_values as $metric_value) {
        $results[] = $metric_value;
    }
	//return $results; // no results beacause $results is an array
    return $results[0]; // get the first result
    
  }

How can I proceed? Do I use before a “__construct” function to build my data (with all values)? Or can I render my data with his multi-values inside the “render” function?

Can you give me explanations and examples? 

Thanks for your help. 

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed