Add 'hydrate' option to the doctrine mapper
This commit is contained in:
parent
c3a15d5035
commit
4c10f1eef8
|
@ -26,16 +26,27 @@ class DoctrineMapper implements MapperInterface
|
|||
*/
|
||||
protected $identifier = null;
|
||||
|
||||
/**
|
||||
* Optional parameters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = array(
|
||||
'hydrate' => true
|
||||
);
|
||||
|
||||
/**
|
||||
* Instanciates a new Mapper
|
||||
*
|
||||
* @param ObjectRepository objectRepository
|
||||
* @param string $identifier
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(ObjectRepository $objectRepository, $identifier = 'id')
|
||||
public function __construct(ObjectRepository $objectRepository, $identifier = 'id', array $options = array())
|
||||
{
|
||||
$this->objectRepository = $objectRepository;
|
||||
$this->identifier = $identifier;
|
||||
$this->options = array_merge($this->options, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,6 +64,7 @@ class DoctrineMapper implements MapperInterface
|
|||
return $this->objectRepository
|
||||
->createQueryBuilder()
|
||||
->field($this->identifier)->in($ids)
|
||||
->hydrate($this->options['hydrate'])
|
||||
->getQuery()
|
||||
->execute();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue