Skip to content

Commit

Permalink
Merge pull request #44 from CakeDC/feature/add-class-and-title-on-lin…
Browse files Browse the repository at this point in the history
…kformatter

remove asserts, add class and title to template for linkformatter
  • Loading branch information
arodu authored May 8, 2024
2 parents d778574 + 635b1c1 commit 704663e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/View/LinkFormatter/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ class Link implements LinkInterface
use LinkTrait;

protected array $_defaultConfig = [
'template' => '<a href=":href" target=":target">:content</a>',
'template' => '<a href=":href" title=":title" target=":target" class=":class">:content</a>',
'url' => null,
'value' => null,
'label' => null,
'value' => '',
'label' => '',
'class' => '',
'disable' => null,
'disableValue' => '',
'type' => Datatables::LINK_TYPE_GET,
Expand All @@ -35,16 +36,18 @@ public function render(): string
unset($url['extra']);
}

$target = $this->getConfig('target');
assert(is_string($target));
$label = $this->getConfig('value');
assert(is_string($label));
$target = (string)$this->getConfig('target');
$value = (string)$this->getConfig('value');
$title = (string)$this->getConfig('title');
$class = (string)$this->getConfig('class');
$htmlLink = Text::insert(
$this->getConfig('template'),
[
'href' => $this->helper->Url->build($url) . $urlExtraValue,
'target' => $target ?: "' + {$target} + '",
'content' => $label ?: "' + {$this->getConfig('value')} + '",
'title' => $title ?: "' + {$title} + '",
'class' => $class ?: "' + {$class} + '",
'content' => $value ?: "' + {$this->getConfig('value')} + '",
]
);

Expand Down

0 comments on commit 704663e

Please sign in to comment.