Browse Source

Allow Template.Icon helper

mscherer 2 years ago
parent
commit
398f8435f7
2 changed files with 16 additions and 1 deletions
  1. 14 1
      src/View/Helper/FormatHelper.php
  2. 2 0
      src/View/Helper/IconHelper.php

+ 14 - 1
src/View/Helper/FormatHelper.php

@@ -8,6 +8,7 @@ use Cake\View\StringTemplate;
 use Cake\View\View;
 use RuntimeException;
 use Shim\Utility\Inflector as ShimInflector;
+use Template\View\Helper\IconHelper;
 
 /**
  * Format helper with basic HTML snippets
@@ -24,7 +25,7 @@ class FormatHelper extends Helper {
 	 *
 	 * @var array
 	 */
-	protected array $helpers = ['Html', 'Tools.Icon'];
+	protected array $helpers = ['Html'];
 
 	/**
 	 * @var \Cake\View\StringTemplate
@@ -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;
 
@@ -60,6 +67,8 @@ class FormatHelper extends Helper {
 	 *   '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
@@ -79,6 +88,8 @@ class FormatHelper extends Helper {
 	 *   '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 :
@@ -190,6 +201,8 @@ class FormatHelper extends Helper {
 	 *   '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)

+ 2 - 0
src/View/Helper/IconHelper.php

@@ -10,6 +10,8 @@ use Tools\View\Icon\IconCollection;
 /**
  * Font icon rendering.
  *
+ * @deprecated Use Template.Icon helper instead.
+ *
  * @author Mark Scherer
  * @license MIT
  */