From a8ff5d47f8f4a91a1fae01519e8ec4952cc7db1f Mon Sep 17 00:00:00 2001 From: kaihoefler <26207541+kaihoefler@users.noreply.github.com> Date: Sun, 24 Mar 2024 10:35:25 +0100 Subject: [PATCH 1/2] Fixing Issue with $constant beeing of type /Cake/ORM/Entity --- src/Model/Behavior/Strategy/ConstStrategy.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Model/Behavior/Strategy/ConstStrategy.php b/src/Model/Behavior/Strategy/ConstStrategy.php index 6bd80fe..735fad9 100644 --- a/src/Model/Behavior/Strategy/ConstStrategy.php +++ b/src/Model/Behavior/Strategy/ConstStrategy.php @@ -132,6 +132,8 @@ public function beforeFind(EventInterface $event, Query $query, ArrayObject $opt $constant = Hash::get($row, $this->getConfig('field')); + if ($constant instanceof Entity) return $row; + $field = Inflector::singularize(Inflector::underscore($this->alias)); $value = new Entity([ 'label' => Hash::get($this->getConstants(), $constant, $constant), From b4393cecb8ac4395fedf372984c25456387d776e 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 2/2] fixed Review comment Fixed "If" without curly brackets break cakephp style guide. --- src/Model/Behavior/Strategy/ConstStrategy.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Model/Behavior/Strategy/ConstStrategy.php b/src/Model/Behavior/Strategy/ConstStrategy.php index 735fad9..638282b 100644 --- a/src/Model/Behavior/Strategy/ConstStrategy.php +++ b/src/Model/Behavior/Strategy/ConstStrategy.php @@ -132,7 +132,9 @@ public function beforeFind(EventInterface $event, Query $query, ArrayObject $opt $constant = Hash::get($row, $this->getConfig('field')); - if ($constant instanceof Entity) return $row; + if ($constant instanceof Entity) { + return $row; + } $field = Inflector::singularize(Inflector::underscore($this->alias)); $value = new Entity([