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

Commit

Permalink
Merge branch 'hotfix/5479' into develop
Browse files Browse the repository at this point in the history
Forward port zendframework/zendframework#5479

Conflicts:
	tests/ZendTest/Form/FormTest.php
  • Loading branch information
weierophinney committed Mar 3, 2014
157 parents cee8165 + 4f3bc98 + 2216b26 + 3edc277 + 265e07a + 7198368 + 1214d4a + 2a94048 + e55039d + b3e6575 + 28a083e + f57823e + 8e9d237 + 4eaa835 + 1d32d23 + bfc0ac0 + 0337874 + ac4e5a4 + 74ad4e1 + 8037ddd + c91b8cb + 442a604 + ce86130 + 6a17c00 + 3be35a1 + b101693 + 38a8855 + 2503264 + 1330305 + c63994b + 0cebe75 + 88437dd + 335a7e0 + 49f818c + 94c6248 + babc2b3 + c5537ad + a278174 + ee91e56 + f730475 + e954d31 + aa83987 + 4272527 + 760e014 + 8f9644f + 89ddc85 + ef5a070 + af19258 + 363ebe6 + 774ea64 + db99c7e + fb3727c + d8ea42f + a5c0289 + 9730940 + ebc1a56 + 1d8cf16 + 09b3859 + efe96d1 + acf177c + 7a7f261 + df4c86b + 4d14dd3 + d0b7057 + c858228 + 8855a3f + 956acc6 + 085a083 + 99b3987 + 59e9d17 + edd16d1 + 17ad876 + 401ed50 + f43d222 + 73ebfdd + da15c07 + 4652c73 + 6a7b288 + 93b11b3 + d67242e + be0deed + c16475f + 68c3d64 + 537f455 + e79de85 + 0cbbdec + 3e0855f + a7a27db + a851ed1 + 86bf6e9 + 9fcf3f0 + c6deb01 + 811568b + 7222979 + 61e594a + 3e10b67 + ecabb9a + 8cdd2bc + 779ae47 + 5ef112f + 7ea9722 + e951b83 + 37c7404 + e730f97 + 43752c5 + ba32611 + 7c15be9 + e3a9518 + cc9ba24 + 5fbd138 + 8bab1da + fa276b4 + 3615cdf + 663ba3c + f0e4074 + c39cf5f + bfa79e5 + 3951384 + 428584d + 9dccbe3 + bc78b89 + 918afd4 + 3ed20dd + 03fd3e7 + 105081b + a6837d0 + 45c4355 + ef30a66 + 06503d1 + 870c487 + 178c8e6 + 059662a + 022a3e8 + 2791c44 + e059c77 + 5011c6b + daa0af0 + 064e54f + 6d4c9af + d0bb055 + 15def87 + b904b9d + 5b6377d + c18bb7b + 11ffd8b + 0fa89e9 + 8ed3edf + 2619551 + 83bf2e2 + 7a23c87 + 8632b61 + 2595c1a + 035e666 + f2ee090 + c7d052f + 11befce + d09ddb8 commit f003b92
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/BaseInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
* @todo How should we deal with required input when data is missing?
* should a message be returned? if so, what message?
*/
class BaseInputFilter implements InputFilterInterface, UnknownInputsCapableInterface, InitializableInterface
class BaseInputFilter implements
InputFilterInterface,
UnknownInputsCapableInterface,
InitializableInterface,
ReplaceableInputInterface
{
protected $data;
protected $inputs = array();
Expand Down Expand Up @@ -84,6 +88,38 @@ public function add($input, $name = null)
return $this;
}

/**
* Replace a named input
*
* @param InputInterface|InputFilterInterface $input
* @param string $name Name of the input to replace
* @throws Exception\InvalidArgumentException
* @return self
*/
public function replace($input, $name)
{
if (!$input instanceof InputInterface && !$input instanceof InputFilterInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'%s expects an instance of %s or %s as its first argument; received "%s"',
__METHOD__,
'Zend\InputFilter\InputInterface',
'Zend\InputFilter\InputFilterInterface',
(is_object($input) ? get_class($input) : gettype($input))
));
}

if (!array_key_exists($name, $this->inputs)) {
throw new Exception\InvalidArgumentException(sprintf(
'%s: no input found matching "%s"',
__METHOD__,
$name
));
}

$this->inputs[$name] = $input;
return $this;
}

/**
* Retrieve a named input
*
Expand Down
19 changes: 19 additions & 0 deletions src/ReplaceableInputInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\InputFilter;

/**
* Mark an input as able to be replaced by another when merging input filters.
*
*/
interface ReplaceableInputInterface
{
public function replace($input, $name);
}

0 comments on commit f003b92

Please sign in to comment.