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

Commit

Permalink
[#2125] Ensure we have a wildcard strategy before attempting to retur…
Browse files Browse the repository at this point in the history
…n it
  • Loading branch information
weierophinney committed Sep 14, 2012
1 parent 87770eb commit c849126
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions library/Zend/Stdlib/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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['*'];
}

Expand All @@ -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);
}

/**
Expand Down

0 comments on commit c849126

Please sign in to comment.