Skip to content

Commit 01ce6a7

Browse files
committed
Icon 2.0.1
1 parent deab68b commit 01ce6a7

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
<a name="2.0.1"></a>
2+
# [2.0.1](https://github.com/flextype-plugins/icon/compare/v2.0.0...v2.0.1) (2021-01-07)
3+
4+
### Bug Fixes
5+
6+
* **core** fix possible issue with null icon name.
7+
18
<a name="2.0.0"></a>
2-
# [2.0.0](https://github.com/flextype-plugins/icon/compare/v1.7.0...v2.0.0) (2021-01-03)
9+
# [2.0.0](https://github.com/flextype-plugins/icon/compare/v1.7.0...v2.0.0) (2021-01-07)
310

411
### Features
512

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Global function `icon()`
4343
/**
4444
* Get SVG icon from specific icons set.
4545
*
46-
* @param string $name Icon name.
46+
* @param string|null $name Icon name.
4747
* @param string|null $set Icon set:
4848
* - tabler
4949
* - bootstrap
@@ -54,7 +54,7 @@ Global function `icon()`
5454
*
5555
* @return string
5656
*/
57-
function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class = null): string
57+
function icon(?string $name = null, ?string $set = 'fontawesome|solid', ?string $class = null): string
5858
```
5959

6060
### Usage

plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Get SVG icon from specific icons set.
1919
*
20-
* @param string $name Icon name.
20+
* @param string|null $name Icon name.
2121
* @param string|null $set Icon set:
2222
* - tabler
2323
* - bootstrap
@@ -28,7 +28,7 @@
2828
*
2929
* @return string
3030
*/
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
3232
{
3333
switch ($set) {
3434
case 'tabler':
@@ -64,12 +64,12 @@ function icon(string $name, ?string $set = 'fontawesome|solid', ?string $class =
6464

6565
// Shortcode: [icon name="apple" set="fontawesome|brands" class=""]
6666
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,
6868
! is_null($s->getParameter('set')) ? $s->getParameter('set') : null,
6969
! is_null($s->getParameter('class')) ? $s->getParameter('class') : '');
7070
});
7171

7272
// 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) {
7474
return icon($name, $set, $class);
7575
}, ['is_safe' => ['html']]));

0 commit comments

Comments
 (0)