zenstruck / redirect-bundle

Store redirects for your site and keeps statistics on redirects and 404 errors.
MIT License
25 stars 8 forks source link

[Bugfix] Drop __constructor with required parameters on models #36

Closed sadikoff closed 6 months ago

sadikoff commented 2 years ago

Hi @kbond

Trying to use the latest version of bundle with PHP8 support we got some bugs =) And this PR should fix all of them I hope.

The main issue was that trying to create an empty object with the form on the project I got a TypeError that I can't assign null to a property defined as string. It's really legit so I looked closer in the code and found that if I create an Redirect with empty string '' data, then setSource() method converts empty string to null and then it fails because $source property is defined as non-nullable... and so on

Also, I got some issues with EasyAdmin because EA instantiates entity with an empty constructor, so I decided to improve this part of the code, and move constructor logic to static create methods.

Cheers!

kbond commented 2 years ago

With #37 merged, there is still a problem with easyadmin?

sadikoff commented 2 years ago

Hey @kbond,

EasyAdmin has a mechanism to change the entity creation process, so it's not a big problem and can be bypassed with one little method in CrudController

Cheers!

kbond commented 2 years ago

Ok, can this pr be closed?