SumField

The Contact Form DB SumField class.

Defined (1)

The class is defined in the following location(s).

/SumField.php  
  1. class SumField extends HistogramTransform { 
  2.  
  3. function __construct($valueField, $groupByField = null) { 
  4. parent::__construct($valueField, $groupByField); 
  5.  
  6. public function addEntry(&$entry) { 
  7. if (array_key_exists($this->valueField, $entry) && is_numeric($entry[$this->valueField])) { 
  8. $value = $entry[$this->valueField]; 
  9. $groupByName = empty($this->groupByField) ? $this->valueField : $entry[$this->groupByField]; 
  10.  
  11. if ($value !== null && $value !== '') { 
  12. if (!array_key_exists($groupByName, $this->values)) { 
  13. $this->values[$groupByName] = $value; 
  14. } else { 
  15. $this->values[$groupByName] += $value;