[Propel] Added new method to return a query to use in
findByIdentifiers(). That way, it's easier to override the default ElasticaToModelTransformer class.
This commit is contained in:
parent
16f621b78f
commit
c1a6728be0
|
@ -114,11 +114,7 @@ class ElasticaToModelTransformer implements ElasticaToModelTransformerInterface
|
|||
return array();
|
||||
}
|
||||
|
||||
$queryClass = $class.'Query';
|
||||
$filterMethod = 'filterBy'.$this->camelize($identifierField);
|
||||
$query = $queryClass::create()
|
||||
->$filterMethod($identifierValues)
|
||||
;
|
||||
$query = $this->createQuery($class, $identifierField, $identifierValues);
|
||||
|
||||
if (!$hydrate) {
|
||||
return $query->toArray();
|
||||
|
@ -127,6 +123,24 @@ class ElasticaToModelTransformer implements ElasticaToModelTransformerInterface
|
|||
return $query->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a query to use in the findByIdentifiers() method.
|
||||
*
|
||||
* @param string $class the model class
|
||||
* @param string $identifierField like 'id'
|
||||
* @param array $identifierValues ids values
|
||||
* @return \ModelCriteria
|
||||
*/
|
||||
protected function createQuery($class, $identifierField, array $identifierValues)
|
||||
{
|
||||
$queryClass = $class.'Query';
|
||||
$filterMethod = 'filterBy'.$this->camelize($identifierField);
|
||||
|
||||
return $queryClass::create()
|
||||
->$filterMethod($identifierValues)
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Util/Inflector.php
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue