Skip to content

Commit

Permalink
Allow Template.Icon helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Dec 10, 2023
1 parent 7001a5e commit 398f843
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/View/Helper/FormatHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Cake\View\View;
use RuntimeException;
use Shim\Utility\Inflector as ShimInflector;
use Template\View\Helper\IconHelper;

/**
* Format helper with basic HTML snippets
Expand All @@ -24,7 +25,7 @@ class FormatHelper extends Helper {
*
* @var array
*/
protected array $helpers = ['Html', 'Tools.Icon'];
protected array $helpers = ['Html'];

/**
* @var \Cake\View\StringTemplate
Expand All @@ -47,6 +48,12 @@ class FormatHelper extends Helper {
* @param array<string, mixed> $config
*/
public function __construct(View $View, array $config = []) {
if (class_exists(IconHelper::class)) {
$this->helpers[] = 'Template.Icon';
} else {
$this->helpers[] = 'Tools.Icon';
}

$defaults = (array)Configure::read('Format') + $this->_defaults;
$config += $defaults;

Expand All @@ -60,6 +67,8 @@ public function __construct(View $View, array $config = []) {
* 'pro' => 'fa4:thumbs-up',
* 'contra' => 'fa4:thumbs-down',
*
* @deprecated Use Template.IconSnippet helper instead.
*
* @param mixed $value Boolish value
* @param array<string, mixed> $options
* @param array<string, mixed> $attributes
Expand All @@ -79,6 +88,8 @@ public function thumbs($value, array $options = [], array $attributes = []): str
* 'prev' => 'fa4:arrow-left',
* 'next' => 'fa4:arrow-right',
*
* @deprecated Use Template.IconSnippet helper instead.
*
* @param array $neighbors (containing prev and next)
* @param string $field Field as `Field` or `Model.field` syntax
* @param array<string, mixed> $options :
Expand Down Expand Up @@ -190,6 +201,8 @@ public function genderIcon($value, array $options = [], array $attributes = []):
* 'yes' => 'fa4:check',
* 'no' => 'fa4:times',
*
* @deprecated Use Template.IconSnippet helper instead.
*
* @param int|bool $value Value
* @param array<string, mixed> $options
* - on (defaults to 1/true)
Expand Down
2 changes: 2 additions & 0 deletions src/View/Helper/IconHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/**
* Font icon rendering.
*
* @deprecated Use Template.Icon helper instead.
*
* @author Mark Scherer
* @license MIT
*/
Expand Down

0 comments on commit 398f843

Please sign in to comment.