Skip to content

Commit

Permalink
Remove filters from final hydrators
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed May 20, 2014
1 parent 3053ac8 commit b546754
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
6 changes: 0 additions & 6 deletions src/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ abstract class AbstractHydrator implements HydratorInterface
use ProvidesNamingStrategyTrait;
use ProvidesStrategyTrait;

/**
* @var FilterChain
*/
protected $filterChain;

/**
* @var ExtractionContext
*/
Expand All @@ -45,7 +40,6 @@ abstract class AbstractHydrator implements HydratorInterface
*/
public function __construct()
{
$this->filterChain = new FilterChain();
$this->namingStrategy = new UnderscoreNamingStrategy();
$this->extractionContext = new ExtractionContext();
$this->hydrationContext = new HydrationContext();
Expand Down
5 changes: 0 additions & 5 deletions src/Hydrator/ArraySerializableHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public function extract($object)
$context->object = $object;

foreach ($data as $property => $value) {
if (!$this->filterChain->accept($property, $context)) {
unset($data[$property]);
continue;
}

$property = $this->namingStrategy->getNameForExtraction($property, $context);
$result[$property] = $this->extractValue($property, $value, $context);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Hydrator/ClassMethodsHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Hydrator;

use Hydrator\Filter\CompositeFilter;
use Hydrator\Filter\FilterChain;
use Hydrator\Filter\GetFilter;
use Hydrator\Filter\HasFilter;
use Hydrator\Filter\IsFilter;
Expand All @@ -27,6 +28,11 @@
*/
final class ClassMethodsHydrator extends AbstractHydrator
{
/**
* @var FilterChain
*/
protected $filterChain;

/**
* Holds the methods for a given object
*
Expand Down Expand Up @@ -57,6 +63,8 @@ public function __construct()
{
parent::__construct();

$this->filterChain = new FilterChain();

$this->filterChain->andFilter(new CompositeFilter(
[new GetFilter(), new IsFilter(), new HasFilter()],
CompositeFilter::TYPE_OR
Expand Down
5 changes: 0 additions & 5 deletions src/Hydrator/ObjectPropertyHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ public function extract($object)
$context->object = $object;

foreach ($data as $property => $value) {
if (!$this->filterChain->accept($property, $context)) {
unset($data[$property]);
continue;
}

$property = $this->namingStrategy->getNameForExtraction($property, $context);
$result[$property] = $this->extractValue($property, $value, $context);
}
Expand Down
4 changes: 0 additions & 4 deletions src/Hydrator/ReflectionHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ public function extract($object)
foreach (self::getReflProperties($object) as $property) {
$propertyName = $this->namingStrategy->getNameForExtraction($property->getName(), $context);

if (!$this->filterChain->accept($property, $context)) {
continue;
}

$value = $property->getValue($object);
$result[$propertyName] = $this->extractValue($propertyName, $value, $context);
}
Expand Down

0 comments on commit b546754

Please sign in to comment.