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

Commit

Permalink
Resolved merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Jun 25, 2012
10 parents dd4a335 + 3569d8b + 00def10 + ecae47b + 0e552a5 + 4f854c2 + 2b17650 + c1c0447 + 73b1f80 + 4a63d7f commit a40eb42
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 372 deletions.
41 changes: 19 additions & 22 deletions src/StaticValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

namespace Zend\Validator;

use Zend\Loader\Broker;

/**
* @category Zend
* @package Zend_Validate
Expand All @@ -31,32 +29,36 @@
class StaticValidator
{
/**
* @var Zend\Loader\Broker
* @var ValidatorPluginManager
*/
protected static $broker;
protected static $plugins;

/**
* Set plugin broker to use for locating validators
* Set plugin manager to use for locating validators
*
* @param Broker|null $broke
* @param ValidatorPluginManager|null $plugins
* @return void
*/
public static function setBroker(Broker $broker = null)
public static function setPluginManager(ValidatorPluginManager $plugins = null)
{
self::$broker = $broker;
// Don't share by default to allow different arguments on subsequent calls
if ($plugins instanceof ValidatorPluginManager) {
$plugins->setShareByDefault(false);
}
self::$plugins = $plugins;
}

/**
* Get plugin broker for locating validators
* Get plugin manager for locating validators
*
* @return Broker
* @return ValidatorPluginManager
*/
public static function getBroker()
public static function getPluginManager()
{
if (null === self::$broker) {
static::setBroker(new ValidatorBroker());
if (null === self::$plugins) {
static::setPluginManager(new ValidatorPluginManager());
}
return self::$broker;
return self::$plugins;
}

/**
Expand All @@ -68,14 +70,9 @@ public static function getBroker()
*/
public static function execute($value, $classBaseName, array $args = array())
{
$broker = static::getBroker();

$validator = $broker->load($classBaseName, $args);
$result = $validator->isValid($value);

// Unregister validator in case different args are used on later invocation
$broker->unregister($classBaseName);
$plugins = static::getPluginManager();

return $result;
$validator = $plugins->get($classBaseName, $args);
return $validator->isValid($value);
}
}
54 changes: 0 additions & 54 deletions src/ValidatorBroker.php

This file was deleted.

46 changes: 18 additions & 28 deletions src/ValidatorChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Validate
* @package Zend_Validator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Validator;

use Countable;
use Zend\Loader\Broker;
use Zend\Loader\Pluggable;

/**
* @category Zend
* @package Zend_Validate
* @package Zend_Validator
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ValidatorChain implements
Countable,
Pluggable,
ValidatorInterface
{
/**
* @var Broker
* @var ValidatorPluginManager
*/
protected $broker;
protected $plugins;

/**
* Validator chain
Expand Down Expand Up @@ -73,34 +70,27 @@ public function count()
}

/**
* Get plugin broker instance
* Get plugin manager instance
*
* @return Zend\Loader\Broker
* @return ValidatorPluginManager
*/
public function getBroker()
public function getPluginManager()
{
if (!$this->broker) {
$this->setBroker(new ValidatorBroker());
if (!$this->plugins) {
$this->setPluginManager(new ValidatorPluginManager());
}
return $this->broker;
return $this->plugins;
}

/**
* Set plugin broker instance
* Set plugin manager instance
*
* @param string|Broker $broker Plugin broker to load plugins
* @param ValidatorPluginManager $plugins Plugin manager
* @return ValidatorChain
*/
public function setBroker($broker)
public function setPluginManager(ValidatorPluginManager $plugins)
{
if (!$broker instanceof Broker) {
throw new Exception\RuntimeException(sprintf(
'%s expects an argument of type Zend\Loader\Broker; received "%s"',
__METHOD__,
(is_object($broker) ? get_class($broker) : gettype($broker))
));
}
$this->broker = $broker;
$this->plugins = $plugins;
return $this;
}

Expand All @@ -113,8 +103,8 @@ public function setBroker($broker)
*/
public function plugin($name, array $options = null)
{
$broker = $this->getBroker();
return $broker->load($name, $options);
$plugins = $this->getPluginManager();
return $plugins->get($name, $options);
}

/**
Expand Down Expand Up @@ -156,7 +146,7 @@ public function prependValidator(ValidatorInterface $validator, $breakChainOnFai
}

/**
* Use the plugin broker to add a validator by name
* Use the plugin manager to add a validator by name
*
* @param string $name
* @param array $options
Expand All @@ -171,7 +161,7 @@ public function addByName($name, $options = array(), $breakChainOnFailure = fals
}

/**
* Use the plugin broker to prepend a validator by name
* Use the plugin manager to prepend a validator by name
*
* @param string $name
* @param array $options
Expand Down
Loading

0 comments on commit a40eb42

Please sign in to comment.