laminas / laminas-form

Validate and display simple and complex forms, casting forms to business objects and vice versa
https://docs.laminas.dev/laminas-form/
BSD 3-Clause "New" or "Revised" License
80 stars 52 forks source link

Remove Zend\I18n\View\Helper\AbstractTranslatorHelper dependency #50

Open michalbundyra opened 4 years ago

michalbundyra commented 4 years ago

This is a follow-on from #32.

You cannot use the view helpers without requiring zend-view. This is because Zend\Form\View\Helper\AbstractHelper extends Zend\I18n\View\Helper\AbstractTranslatorHelper, which in turn extends Zend\View\Helper\AbstractHelper.

I would like to break this dependency. After a quick scan it looks like implementing the setView() / getView() / setTranslator() / getTranslator() methods in the abstract helper would do the trick. Would this be the right approach?


Originally posted by @kynx at https://github.com/zendframework/zend-form/issues/41

michalbundyra commented 4 years ago

Unfortunately, it won't. AbstractHelper also implements HelperInterface, which all helpers need to implement. So while you'd remove the need to extend the base helper from zend-view, you'd still have the dependency due to the interface.


Originally posted by @weierophinney at https://github.com/zendframework/zend-form/issues/41#issuecomment-184049831

michalbundyra commented 4 years ago

Gack :|

OK, so how about moving the core functionality to Zend\Form\Helper or similar and have Zend\Form\View\Helper\* proxy the core helpers?

That should be possible without a BC break (me, eternal optimist ;) and could provide a path towards moving them over to zend-view in future (discoverability / fewer suggests, as discussed over at https://github.com/zendframework/zend-validator/issues/1).


Originally posted by @kynx at https://github.com/zendframework/zend-form/issues/41#issuecomment-184107598

michalbundyra commented 4 years ago

@kynx II like the idea that you have exposed in https://github.com/zendframework/zend-form/issues/32. i.e having a separate package for the view helpers dependent on zend-form and zend-view. kind regards


Originally posted by @pine3ree at https://github.com/zendframework/zend-form/issues/41#issuecomment-224005124

michalbundyra commented 4 years ago

I'm a newbie and this just bit me for a few minutes with a 26-level stack trace. Figured it out eventually, but should zendframework/zend-i18n be a composer dependency of zendframework/zend-form so that it gets brought in, until this issue is figured out by the big brains?


Originally posted by @bitwombat at https://github.com/zendframework/zend-form/issues/41#issuecomment-262690291

michalbundyra commented 4 years ago

@bitwombat

should zendframework/zend-i18n be a composer dependency of zendframework/zend-form so that it gets brought in

It is already there. See composer.json:

"suggest": {
    "zendframework/zend-i18n": "^2.6, required when using zend-form view helpers",
}

https://github.com/zendframework/zend-form/blob/master/composer.json#L46

Why suggest section in composer? Not everyone uses the view / output part of zend-form.


Originally posted by @froschdesign at https://github.com/zendframework/zend-form/issues/41#issuecomment-262707580

michalbundyra commented 4 years ago

Not everyone uses the view / output part of zend-form.

Ah, got it. So I should have read the 'suggested' output from composer better.

Thanks for the reply.


Originally posted by @bitwombat at https://github.com/zendframework/zend-form/issues/41#issuecomment-262757677

samsonasik commented 4 years ago

I am closing it. As stated, there is i18n component in suggest in composer.json

froschdesign commented 4 years ago

@samsonasik Please have a look at the original description of this issue report because the problem is not the Composer configuration.

samsonasik commented 4 years ago

@froschdesign ok, I re-open it.