MakeLink
extends AbstractHelper
in package
Make link view helper
Tags
Table of Contents
- __invoke() : string
- Render an HTML link
- mergeAttributes() : array<string|int, mixed>
- Combine attributes including proxy
Methods
__invoke()
Render an HTML link
public
__invoke(string $contents[, string $href = null ][, string|array<string|int, mixed> $attrs = [] ][, array<string|int, mixed> $options = [] ]) : string
$href will override $attrs['href']
Feel free to use like makeLink('text', 'href', $defaults);
If no $href, will try to find an href in $attrs
makeLink('text', null, ['href' => '#', 'class' => 'btn-link'])
If $attrs is a string, will be treated like a class
makeLink('text', $href, 'btn-link')
Additional options
- proxyUrl: proxy url prefix before href
- escapeContent: Default true, set to false to skip escaping (like for HTML).
Parameters
- $contents : string
-
Link contents (must be properly-formed HTML)
- $href : string = null
-
Link destination (null to skip)
- $attrs : string|array<string|int, mixed> = []
-
Link attributes (class name / associative array)
- $options : array<string|int, mixed> = []
-
Additional options
Return values
string —HTML for an anchor tag
mergeAttributes()
Combine attributes including proxy
protected
mergeAttributes(string $href, string|array<string|int, mixed> $attrs, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $href : string
-
Link destination (null to skip)
- $attrs : string|array<string|int, mixed>
-
Link attributes (class name or associative array)
- $options : array<string|int, mixed>
-
Additional options
Return values
array<string|int, mixed> —(associative) Combined attributes by key