コード例 #1
0
ファイル: Link.php プロジェクト: deltasystems/dewdrop
 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;
         }
     });
 }