Skip to content

Commit 398f843

Browse files
committed
Allow Template.Icon helper
1 parent 7001a5e commit 398f843

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/View/Helper/FormatHelper.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Cake\View\View;
99
use RuntimeException;
1010
use Shim\Utility\Inflector as ShimInflector;
11+
use Template\View\Helper\IconHelper;
1112

1213
/**
1314
* Format helper with basic HTML snippets
@@ -24,7 +25,7 @@ class FormatHelper extends Helper {
2425
*
2526
* @var array
2627
*/
27-
protected array $helpers = ['Html', 'Tools.Icon'];
28+
protected array $helpers = ['Html'];
2829

2930
/**
3031
* @var \Cake\View\StringTemplate
@@ -47,6 +48,12 @@ class FormatHelper extends Helper {
4748
* @param array<string, mixed> $config
4849
*/
4950
public function __construct(View $View, array $config = []) {
51+
if (class_exists(IconHelper::class)) {
52+
$this->helpers[] = 'Template.Icon';
53+
} else {
54+
$this->helpers[] = 'Tools.Icon';
55+
}
56+
5057
$defaults = (array)Configure::read('Format') + $this->_defaults;
5158
$config += $defaults;
5259

@@ -60,6 +67,8 @@ public function __construct(View $View, array $config = []) {
6067
* 'pro' => 'fa4:thumbs-up',
6168
* 'contra' => 'fa4:thumbs-down',
6269
*
70+
* @deprecated Use Template.IconSnippet helper instead.
71+
*
6372
* @param mixed $value Boolish value
6473
* @param array<string, mixed> $options
6574
* @param array<string, mixed> $attributes
@@ -79,6 +88,8 @@ public function thumbs($value, array $options = [], array $attributes = []): str
7988
* 'prev' => 'fa4:arrow-left',
8089
* 'next' => 'fa4:arrow-right',
8190
*
91+
* @deprecated Use Template.IconSnippet helper instead.
92+
*
8293
* @param array $neighbors (containing prev and next)
8394
* @param string $field Field as `Field` or `Model.field` syntax
8495
* @param array<string, mixed> $options :
@@ -190,6 +201,8 @@ public function genderIcon($value, array $options = [], array $attributes = []):
190201
* 'yes' => 'fa4:check',
191202
* 'no' => 'fa4:times',
192203
*
204+
* @deprecated Use Template.IconSnippet helper instead.
205+
*
193206
* @param int|bool $value Value
194207
* @param array<string, mixed> $options
195208
* - on (defaults to 1/true)

src/View/Helper/IconHelper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
/**
1111
* Font icon rendering.
1212
*
13+
* @deprecated Use Template.Icon helper instead.
14+
*
1315
* @author Mark Scherer
1416
* @license MIT
1517
*/

0 commit comments

Comments
 (0)