Allow specifying "break chain on failure" flag as Validator option #5780

Merged
merged 2 commits into from Feb 3, 2014

Projects

None yet

2 participants

@weierophinney
Member
  • When calling attachByName(), allow passing the "break chain on failure"
    flag
    as an option, instead of requiring it to be passed as the third argument to
    the method; simplifies factories.
  • Fixes zfcampus/zf-apigility-admin#89
@weierophinney weierophinney Allow specifying "break chain on failure" flag as option
- When calling `attachByName()`, allow passing the "break chain on failure" flag
  as an option, instead of requiring it to be passed as the third argument to
  the method; simplifies factories.

- Fixes zfcampus/zf-apigility-admin#89
7dc83b5
@Maks3w Maks3w commented on the diff Feb 3, 2014
library/Zend/Validator/ValidatorChain.php
@@ -146,6 +146,14 @@ public function prependValidator(ValidatorInterface $validator, $breakChainOnFai
*/
public function attachByName($name, $options = array(), $breakChainOnFailure = false)
{
+ if (isset($options['break_chain_on_failure'])) {
+ $breakChainOnFailure = (bool) $options['break_chain_on_failure'];
+ }
+
+ if (isset($options['breakchainonfailure'])) {
+ $breakChainOnFailure = (bool) $options['breakchainonfailure'];
@Maks3w
Maks3w Feb 3, 2014 Member

Sincerely I don't like to have different ways of write the same thing. IMO this is an overhead for the framework.

Anyway, If you consider this necessary please add a test case for this option too.

@weierophinney
weierophinney Feb 3, 2014 Member

I'll add a test case -- mainly because it's documented both ways in different locations.

@Maks3w
Maks3w Feb 3, 2014 Member

For the record:
The uses of these config keys are in Zend/File/Transfer/Adapter/AbstractAdapter.php and Zend/InputFilter/Factory.php

@weierophinney weierophinney Ensure both flags are tested
- Wrote a data provider so that the option name both with and without
  underscores may be tested.
0e057af
@Maks3w Maks3w merged commit 95e1d90 into zendframework:develop Feb 3, 2014

1 check passed

default The Travis CI build passed
Details
@weierophinney weierophinney deleted the weierophinney:hotfix/zf-apigility-admin-89 branch Feb 3, 2014
@gianarb gianarb pushed a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@Maks3w Maks3w Merge pull request zendframework/zendframework#5780 from weierophinne…
…y/hotfix/zf-apigility-admin-89

Allow specifying "break chain on failure" flag as Validator option
abdbc4a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment