Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fixing prepended NotEmpty validator #7003

Closed
wants to merge 1 commit into from
Closed

Fixing prepended NotEmpty validator #7003

wants to merge 1 commit into from

Conversation

gabrielsch
Copy link
Contributor

When using InputFilter standalone (without dev dependencies), this is broken because this line calls ValidatorPluginManager, and this class inherits AbstractPluginManager, that is suggested at composer.json, not required.

Then the following error is thrown:
PHP Fatal error: Class 'Zend\ServiceManager\AbstractPluginManager' not found in /zf2/library/Zend/Validator/ValidatorPluginManager.php on line 16

I just changed the prependByName method (that uses PluginManager) to prependValidator, instantiating the validator by hand.

@danizord
Copy link
Contributor

danizord commented Dec 9, 2014

👍

1 similar comment
@fabiocarneiro
Copy link
Contributor

👍

@Ocramius
Copy link
Member

Ocramius commented Dec 9, 2014

While I agree with the change, this is also a BC break, since your validator will now come with untranslated messages, and overriding the default 'NotEmpty' will become problematic without subclassing the 'Input' class.

@gabrielsch
Copy link
Contributor Author

@Ocramius but this would not be a bug? I can't use the InputFilter component without ServiceManager, it's a big problem IMO, or maybe we should put zend-servicemanager as a required dep.

@Ocramius
Copy link
Member

Ocramius commented Dec 9, 2014

@gabrielsch I'd rather fix the problem via a class_exists() somewhere instead.

@Ocramius
Copy link
Member

Ocramius commented Dec 9, 2014

To be precise, prependByName should work with or without ServiceManager IMO

@weierophinney
Copy link
Member

Suggestion: test to see if class_exists('Zend\ServiceManager\AbstractPluginManager'), and use prependByName() if it's present, and prependValidator() if not.

@weierophinney weierophinney added this to the 2.4.0 milestone Feb 19, 2015
@gabrielsch
Copy link
Contributor Author

ok @weierophinney, I'll finish that soon

@gabrielsch
Copy link
Contributor Author

done @weierophinney , sorry for the delay 😄

weierophinney added a commit that referenced this pull request Mar 10, 2015
Fixing prepended `NotEmpty` validator
weierophinney added a commit that referenced this pull request Mar 10, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

@gabrielsch gabrielsch deleted the bugfix/input-not-empty branch March 11, 2015 15:22
weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request May 15, 2015
…ugfix/input-not-empty

Fixing prepended `NotEmpty` validator
weierophinney added a commit to zendframework/zend-inputfilter that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants