public function __invoke(FieldInterface $field) { $field->addHelperFilter('TableCell.Content', function ($content, TableCell $helper, array $rowData, $rowIndex, $columnIndex) { if (!$content) { return $content; } return $helper->getView()->escapeHtml(sprintf($this->template, $content)); }); $field->addHelperFilter('CsvCell.Content', function ($content, CsvCell $helper, array $rowData, $rowIndex, $columnIndex) { if (!$content) { return $content; } return sprintf($this->template, $content); }); }
public function __invoke(FieldInterface $field) { $field->addHelperFilter('TableCell.Content', function ($content, TableCell $helper, array $rowData, $rowIndex, $columnIndex) { if (!$content) { return null; } if (!$this->urlTemplate || !isset($rowData[$this->id]) || !$rowData[$this->id]) { return $content; } else { $node = new Node('a'); $node->setHtml($content)->setAttribute('href', sprintf($this->urlTemplate, $rowData[$this->id]))->setAttribute('class', implode(' ', $this->cssClasses)); if ($this->title) { $node->setAttribute('title', $this->title); } if ($this->target) { $node->setAttribute('target', $this->target); } return $node; } }); }