Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in ConstStrategy while formatig results #55

Closed
kaihoefler opened this issue Mar 24, 2024 · 2 comments · Fixed by #56
Closed

Error in ConstStrategy while formatig results #55

kaihoefler opened this issue Mar 24, 2024 · 2 comments · Fixed by #56

Comments

@kaihoefler
Copy link
Contributor

I get the following error when I use the const strategy with enum:

Cake\Utility\Hash::get(): Argument #2 ($path) must be of type array|string|int|null, Cake\ORM\Entity given, called in /application/vendor/cakedc/enum/src/Model/Behavior/Strategy/ConstStrategy.php on line 133

The situation i experience is that while iterating through the result set of a query the $row in the beforeFind event already has been formated and is of type Cake\ORM\Entity.

I do not understand how this happens, but it can be fixed by adding the line

if ($constant instanceof Entity) return $row; after line 128 in the class ConstStrategy.

@arusinowski
Copy link
Member

@kaihoefler thank you for reporting this issue. I see that you are using the dev version, there is stable version 3.0.0 with support for CakePHP5.0, did you tried to use this version instead?

@jay-eventrac
Copy link

jay-eventrac commented Apr 9, 2024

@arusinowski , It is working fine in CakePHP3 and enum package version '1.4.0'.

But, I upgraded the project from CakePHP3 to CakePHP4. I am using version 2.1.0 for CakePHP4 and facing the same problem. Can you fix it for CakePHP4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants