Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Replaced newInstanceWithoutConstructor with doctrine\instantiator
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHAnderson committed Jan 16, 2015
1 parent 083f9a2 commit 1036ca4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"zendframework/zend-modulemanager": "2.*",
"zendframework/zend-servicemanager": "2.*",
"zendframework/zend-stdlib": "2.*",
"doctrine/doctrine-module": ">=0.8.0"
"doctrine/doctrine-module": ">=0.8.0",
"doctrine/instantiator": "~1.0.4"
},
"require-dev": {
"fabpot/PHP-CS-Fixer": "*",
Expand Down
5 changes: 3 additions & 2 deletions src/Hydrator/ODM/MongoDB/Strategy/EmbeddedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Doctrine\Common\Collections\Collection;
use DoctrineModule\Stdlib\Hydrator;
use Doctrine\Instantiator\Instantiator;

/**
* Class PersistentCollection
Expand Down Expand Up @@ -92,8 +93,8 @@ protected function hydrateSingle($targetDocument, $document)
return $document;
}

$rc = new \ReflectionClass($targetDocument);
$object = $rc->newInstance();
$instantiator = new Instantiator();
$object = $instantiator->instantiate($targetDocument);

$hydrator = $this->getDoctrineHydrator($targetDocument);
$hydrator->hydrate($document, $object);
Expand Down
6 changes: 4 additions & 2 deletions src/Hydrator/ODM/MongoDB/Strategy/EmbeddedField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Phpro\DoctrineHydrationModule\Hydrator\ODM\MongoDB\Strategy;

use Doctrine\Instantiator\Instantiator;

/**
* Class PersistentCollection
*
Expand Down Expand Up @@ -39,8 +41,8 @@ public function hydrate($value)
return $value;
}

$rc = new \ReflectionClass($targetDocument);
$object = $rc->newInstance();
$instantiator = new Instantiator();
$object = $instantiator->instantiate($targetDocument);

$hydrator = $this->getDoctrineHydrator($targetDocument);
$hydrator->hydrate($value, $object);
Expand Down

0 comments on commit 1036ca4

Please sign in to comment.