Permalink
Browse files

[#2125] Ensure we have a wildcard strategy before attempting to retur…

…n it
  • Loading branch information...
1 parent 9f8c704 commit 48955452f3cc00598e62ffdf54dda940cb4bd7d4 @weierophinney weierophinney committed Sep 14, 2012
Showing with 12 additions and 2 deletions.
  1. +12 −2 library/Zend/Stdlib/Hydrator/AbstractHydrator.php
@@ -11,6 +11,7 @@
namespace Zend\Stdlib\Hydrator;
use ArrayObject;
+use Zend\Stdlib\Exception;
use Zend\Stdlib\Hydrator\StrategyEnabledInterface;
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;
@@ -44,9 +45,18 @@ public function __construct()
*/
public function getStrategy($name)
{
- if(isset($this->strategies[$name])) {
+ if (isset($this->strategies[$name])) {
return $this->strategies[$name];
}
+
+ if (!isset($this->strategies['*'])) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ '%s: no strategy by name of "%s", and no wildcard strategy present',
+ __METHOD__,
+ $name
+ ));
+ }
+
return $this->strategies['*'];
}
@@ -59,7 +69,7 @@ public function getStrategy($name)
public function hasStrategy($name)
{
return array_key_exists($name, $this->strategies)
- || array_key_exists('*', $this->strategies);
+ || array_key_exists('*', $this->strategies);
}
/**

0 comments on commit 4895545

Please sign in to comment.