Removed unneccesary argument from findByIdentifiers methods
This commit is contained in:
parent
ba75ca8d7b
commit
1626910299
|
@ -72,7 +72,7 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
|
|||
return $elasticaObject->getId();
|
||||
}, $elasticaObjects);
|
||||
|
||||
$objects = $this->findByIdentifiers($this->objectClass, $this->options['identifier'], $ids, $this->options['hydrate']);
|
||||
$objects = $this->findByIdentifiers($ids, $this->options['hydrate']);
|
||||
if (count($objects) < count($elasticaObjects)) {
|
||||
throw new \RuntimeException('Cannot find corresponding Doctrine objects for all Elastica results.');
|
||||
};
|
||||
|
@ -104,11 +104,9 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
|
|||
/**
|
||||
* Fetches objects by theses identifier values
|
||||
*
|
||||
* @param string $class the model class
|
||||
* @param string $identifierField like 'id'
|
||||
* @param array $identifierValues ids values
|
||||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected abstract function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate);
|
||||
protected abstract function findByIdentifiers(array $identifierValues, $hydrate);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
|
|||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate)
|
||||
protected function findByIdentifiers(array $identifierValues, $hydrate)
|
||||
{
|
||||
return $this->objectManager
|
||||
->createQueryBuilder($class)
|
||||
->field($identifierField)->in($identifierValues)
|
||||
->createQueryBuilder($this->objectClass)
|
||||
->field($this->options['identifier'])->in($identifierValues)
|
||||
->hydrate($hydrate)
|
||||
->getQuery()
|
||||
->execute()
|
||||
|
|
|
@ -22,17 +22,17 @@ class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
|
|||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate)
|
||||
protected function findByIdentifiers(array $identifierValues, $hydrate)
|
||||
{
|
||||
if (empty($identifierValues)) {
|
||||
return array();
|
||||
}
|
||||
$hydrationMode = $hydrate ? Query::HYDRATE_OBJECT : Query::HYDRATE_ARRAY;
|
||||
$qb = $this->objectManager
|
||||
->getRepository($class)
|
||||
->getRepository($this->objectClass)
|
||||
->createQueryBuilder('o');
|
||||
/* @var $qb \Doctrine\ORM\QueryBuilder */
|
||||
$qb->where($qb->expr()->in('o.'.$identifierField, ':values'))
|
||||
$qb->where($qb->expr()->in('o.'.$this->options['identifier'], ':values'))
|
||||
->setParameter('values', $identifierValues);
|
||||
|
||||
return $qb->getQuery()->setHydrationMode($hydrationMode)->execute();
|
||||
|
|
|
@ -57,7 +57,7 @@ class ElasticaToModelTransformer implements ElasticaToModelTransformerInterface
|
|||
return $elasticaObject->getId();
|
||||
}, $elasticaObjects);
|
||||
|
||||
$objects = $this->findByIdentifiers($this->objectClass, $this->options['identifier'], $ids, $this->options['hydrate']);
|
||||
$objects = $this->findByIdentifiers($ids, $this->options['hydrate']);
|
||||
|
||||
$identifierGetter = 'get'.ucfirst($this->options['identifier']);
|
||||
|
||||
|
@ -108,13 +108,13 @@ class ElasticaToModelTransformer implements ElasticaToModelTransformerInterface
|
|||
* @param Boolean $hydrate whether or not to hydrate the objects, false returns arrays
|
||||
* @return array of objects or arrays
|
||||
*/
|
||||
protected function findByIdentifiers($class, $identifierField, array $identifierValues, $hydrate)
|
||||
protected function findByIdentifiers(array $identifierValues, $hydrate)
|
||||
{
|
||||
if (empty($identifierValues)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$query = $this->createQuery($class, $identifierField, $identifierValues);
|
||||
$query = $this->createQuery($this->objectClass, $this->options['identifier'], $identifierValues);
|
||||
|
||||
if (!$hydrate) {
|
||||
return $query->toArray();
|
||||
|
|
Loading…
Reference in a new issue