Ejemplo n.º 1
0
 /**
  * Build a Fields object that can be used when rendering the grouped counts.  Supplies a field
  * to render the actual HTML value from the original Fields object used when fetching data for
  * the listing and a field to render the count for that value.  We don't do any escaping here
  * because we assume that the original Fields object handled that in its rendering code.  The
  * fields object returned from this method supports both TableCell and CsvCell rendering.
  *
  * @return Fields
  */
 public function buildRenderFields()
 {
     $fields = new Fields();
     $fields->add('content')->setLabel($this->groupField->getLabel())->setVisible(true)->assignHelperCallback('TableCell.Content', function (TableCell\Content $helper, array $rowData) {
         // Not escaping here because we assume it was escaped by the original renderer in fetchData()
         return $rowData['content'];
     })->assignHelperCallback('CsvCell.Content', function (CsvCell\Content $helper, array $rowData) {
         return $rowData['content'];
     })->add('count')->setLabel('Count')->setVisible(true)->assignHelperCallback('TableCell.Content', function (TableCell\Content $helper, array $rowData) {
         return $helper->getView()->escapeHtml($rowData['count']);
     })->assignHelperCallback('CsvCell.Content', function (CsvCell\Content $helper, array $rowData) {
         return $rowData['count'];
     });
     return $fields;
 }
Ejemplo n.º 2
0
 /**
  * If no custom callback is defined for a field, it will fall back to this
  * method to find a suitable callback.  In the case of the Header helper,
  * we fall back to all fields just returning their labels.
  *
  * @param FieldInterface $field
  * @return callable
  */
 public function detectCallableForField(FieldInterface $field)
 {
     return function () use($field) {
         return $field->getLabel();
     };
 }
Ejemplo n.º 3
0
 /**
  * If no custom callback is defined for a field, it will fall back to this
  * method to find a suitable callback.  In the case of the Header helper,
  * we fall back to all field's just returning their label.
  *
  * @param FieldInterface $field
  * @return callable
  */
 public function detectCallableForField(FieldInterface $field)
 {
     return function () use($field) {
         return $this->view->escapeHtml($field->getLabel());
     };
 }