From b6cab0812194810c764aea23b8bac761e7465a2a Mon Sep 17 00:00:00 2001 From: kaihoefler <26207541+kaihoefler@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:40:30 +0200 Subject: [PATCH] Fixing Issue with beeing of type /Cake/ORM/Entity --- src/Model/Behavior/Strategy/ConstStrategy.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Model/Behavior/Strategy/ConstStrategy.php b/src/Model/Behavior/Strategy/ConstStrategy.php index dc006f9..f98c5c3 100644 --- a/src/Model/Behavior/Strategy/ConstStrategy.php +++ b/src/Model/Behavior/Strategy/ConstStrategy.php @@ -13,6 +13,7 @@ namespace CakeDC\Enum\Model\Behavior\Strategy; +use Cake\ORM\Entity; use Cake\ORM\Table; use Cake\Utility\Hash; use Cake\Utility\Inflector; @@ -123,8 +124,12 @@ public function beforeFind(\Cake\Event\EventInterface $event, \Cake\ORM\Query $q $constant = Hash::get($row, $this->getConfig('field')); + if ($constant instanceof Entity) { + return $row; + } + $field = Inflector::singularize(Inflector::underscore($this->_alias)); - $value = new \Cake\ORM\Entity([ + $value = new Entity([ 'label' => Hash::get($this->_getConstants(), $constant, $constant), 'prefix' => $this->getConfig('prefix'), 'value' => $constant,