|
17 | 17 | /** |
18 | 18 | * Get SVG icon from specific icons set. |
19 | 19 | * |
20 | | - * @param string $name Icon name. |
| 20 | + * @param string|null $name Icon name. |
21 | 21 | * @param string|null $set Icon set: |
22 | 22 | * - tabler |
23 | 23 | * - bootstrap |
|
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | | -function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class = null): string |
| 31 | +function icon(?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null): string |
32 | 32 | { |
33 | 33 | switch ($set) { |
34 | 34 | case 'tabler': |
@@ -64,12 +64,12 @@ function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class = |
64 | 64 |
|
65 | 65 | // Shortcode: [icon name="apple" set="fontawesome|brands" class=""] |
66 | 66 | flextype('parsers')->shortcode()->addHandler('icon', function (ShortcodeInterface $s) { |
67 | | - return icon($s->getParameter('name'), |
| 67 | + return icon(! is_null($s->getParameter('name')) ? $s->getParameter('name') : null, |
68 | 68 | ! is_null($s->getParameter('set')) ? $s->getParameter('set') : null, |
69 | 69 | ! is_null($s->getParameter('class')) ? $s->getParameter('class') : ''); |
70 | 70 | }); |
71 | 71 |
|
72 | 72 | // Twig: {{ icon('apple', 'fontawesome|brands', '') }} |
73 | | -flextype('twig')->addFunction(new TwigFunction('icon', function (string $name, ?string $set = 'fontawesome|solid', ?string $class = null) { |
| 73 | +flextype('twig')->addFunction(new TwigFunction('icon', function (?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null) { |
74 | 74 | return icon($name, $set, $class); |
75 | 75 | }, ['is_safe' => ['html']])); |
0 commit comments