[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:
William DURAND 2012-05-05 18:43:56 +02:00 committed by Richard Miller
parent 16f621b78f
commit c1a6728be0

View file

@ -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
*/