mscherer 2 年之前
父节点
当前提交
4e72a38b8f

+ 3 - 0
docs/Helper/Format.md

@@ -50,6 +50,9 @@ You can alias them via Configure for more usability:
 echo $this->Format->icon('translate', ['title' => 'Translate this']);
 ```
 
+Note: For forward compatibility you can also use 'iconHelper' => true` config to directly forward any old helper call to the new one.
+This can be useful for the ones inside plugins you do not control.
+
 ### yesNo()
 
 Displays yes/no symbol for e.g. boolean values as more user friendly representation.

+ 6 - 4
src/Model/Entity/Token.php

@@ -4,14 +4,14 @@ namespace Tools\Model\Entity;
 
 /**
  * @property int $id
- * @property int $user_id
+ * @property int|null $user_id
  * @property string $type
  * @property string $token_key
  * @property string $key Deprecated, use token_key instead.
- * @property string $content
+ * @property string|null $content
  * @property int $used
- * @property \Cake\I18n\Time $created
- * @property \Cake\I18n\Time $modified
+ * @property \Cake\I18n\FrozenTime|null $created
+ * @property \Cake\I18n\FrozenTime|null $modified
  * @property bool $unlimited
  */
 class Token extends Entity {
@@ -22,6 +22,7 @@ class Token extends Entity {
 	 * @deprecated Use token_key instead.
 	 *
 	 * @return string|null
+	 * @see \Tools\Model\Entity\Token::$key
 	 */
 	public function _getKey(): ?string {
 		trigger_error('Deprecated. Use ->token_key instead.', E_USER_DEPRECATED);
@@ -37,6 +38,7 @@ class Token extends Entity {
 	 * @param string|null $key
 	 *
 	 * @return void
+	 * @see \Tools\Model\Entity\Token::$key
 	 */
 	public function _setKey(?string $key): void {
 		trigger_error('Deprecated. Use ->token_key instead.', E_USER_DEPRECATED);

+ 9 - 3
src/Model/Table/TokensTable.php

@@ -13,12 +13,18 @@ use RuntimeException;
  * @author Mark Scherer
  * @license http://opensource.org/licenses/mit-license.php MIT
  * @method \Tools\Model\Entity\Token get($primaryKey, $options = [])
- * @method \Tools\Model\Entity\Token newEntity($data = null, array $options = [])
+ * @method \Tools\Model\Entity\Token newEntity(array $data, array $options = [])
  * @method array<\Tools\Model\Entity\Token> newEntities(array $data, array $options = [])
  * @method \Tools\Model\Entity\Token|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
  * @method \Tools\Model\Entity\Token patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
- * @method array<\Tools\Model\Entity\Token> patchEntities($entities, array $data, array $options = [])
- * @method \Tools\Model\Entity\Token findOrCreate($search, callable $callback = null, $options = [])
+ * @method array<\Tools\Model\Entity\Token> patchEntities(iterable $entities, array $data, array $options = [])
+ * @method \Tools\Model\Entity\Token findOrCreate($search, ?callable $callback = null, $options = [])
+ * @method \Tools\Model\Entity\Token newEmptyEntity()
+ * @method \Tools\Model\Entity\Token saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
+ * @method \Cake\Datasource\ResultSetInterface<\Tools\Model\Entity\Token>|false saveMany(iterable $entities, $options = [])
+ * @method \Cake\Datasource\ResultSetInterface<\Tools\Model\Entity\Token> saveManyOrFail(iterable $entities, $options = [])
+ * @method \Cake\Datasource\ResultSetInterface<\Tools\Model\Entity\Token>|false deleteMany(iterable $entities, $options = [])
+ * @method \Cake\Datasource\ResultSetInterface<\Tools\Model\Entity\Token> deleteManyOrFail(iterable $entities, $options = [])
  */
 class TokensTable extends Table {
 

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

@@ -18,6 +18,7 @@ use Shim\Utility\Inflector as ShimInflector;
  * @author Mark Scherer
  * @license MIT
  * @property \Cake\View\Helper\HtmlHelper $Html
+ * @property \Tools\View\Helper\IconHelper $Icon
  */
 class FormatHelper extends Helper {
 
@@ -26,7 +27,7 @@ class FormatHelper extends Helper {
 	 *
 	 * @var array
 	 */
-	protected $helpers = ['Html'];
+	protected $helpers = ['Html', 'Tools.Icon'];
 
 	/**
 	 * @var \Cake\View\StringTemplate
@@ -67,6 +68,7 @@ class FormatHelper extends Helper {
 			'ok' => '<span class="ok-{{type}}" style="color:{{color}}"{{attributes}}>{{content}}</span>',
 		],
 		'slugger' => null,
+		'iconHelper' => false, // FC with new Icon helper
 	];
 
 	/**
@@ -266,6 +268,9 @@ class FormatHelper extends Helper {
 		if (!$icon) {
 			return '';
 		}
+		if ($this->getConfig('iconHelper')) {
+			return $this->Icon->render($icon, $options, $attributes);
+		}
 
 		$defaults = [
 			'translate' => true,

+ 0 - 1
src/View/Icon/IconCollection.php

@@ -129,7 +129,6 @@ class IconCollection {
 		}
 
 		unset($options['attributes']);
-
 		if ($this->getConfig('checkExistence') && !$this->exists($icon, $set)) {
 			trigger_error(sprintf('Icon `%s` does not exist', $set . ':' . $icon), E_USER_WARNING);
 		}