Add DoctrineMongoDBProvider and DoctrineORMProvider to deal with count inconsistency
This commit is contained in:
parent
f071c98143
commit
aed89aa8dc
5 changed files with 42 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ use Elastica_Document;
|
|||
use Closure;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class DoctrineProvider implements ProviderInterface
|
||||
abstract class AbstractDoctrineProvider implements ProviderInterface
|
||||
{
|
||||
protected $type;
|
||||
protected $objectManager;
|
||||
|
|
@ -66,6 +66,13 @@ class DoctrineProvider implements ProviderInterface
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @return int
|
||||
**/
|
||||
protected abstract function countObjects($queryBuilder);
|
||||
|
||||
/**
|
||||
* Creates the query buider used to fetch the documents to index
|
||||
*
|
||||
16
Provider/DoctrineMongoDBProvider.php
Normal file
16
Provider/DoctrineMongoDBProvider.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Provider;
|
||||
|
||||
class DoctrineMongoDBProvider extends AbstractDoctrineProvider
|
||||
{
|
||||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @return int
|
||||
**/
|
||||
protected function countObjects($queryBuilder)
|
||||
{
|
||||
return $queryBuilder->getQuery()->count();
|
||||
}
|
||||
}
|
||||
16
Provider/DoctrineORMProvider.php
Normal file
16
Provider/DoctrineORMProvider.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle\Provider;
|
||||
|
||||
class DoctrineORMProvider extends AbstractDoctrineProvider
|
||||
{
|
||||
/**
|
||||
* Counts the objects of a query builder
|
||||
*
|
||||
* @return int
|
||||
**/
|
||||
protected function countObjects($queryBuilder)
|
||||
{
|
||||
return $queryBuilder->count()->getQuery()->execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<services>
|
||||
|
||||
<service id="foq_elastica.provider.prototype.mongodb" class="FOQ\ElasticaBundle\Provider\DoctrineProvider" public="false" abstract="true">
|
||||
<service id="foq_elastica.provider.prototype.mongodb" class="FOQ\ElasticaBundle\Provider\DoctrineMongoDBProvider" public="false" abstract="true">
|
||||
<argument /> <!-- index -->
|
||||
<argument type="service" id="doctrine.odm.mongodb.document_manager" />
|
||||
<argument /> <!-- transformer -->
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<services>
|
||||
|
||||
<service id="foq_elastica.provider.prototype.orm" class="FOQ\ElasticaBundle\Provider\DoctrineProvider" public="false" abstract="true">
|
||||
<service id="foq_elastica.provider.prototype.orm" class="FOQ\ElasticaBundle\Provider\DoctrineORMProvider" public="false" abstract="true">
|
||||
<argument /> <!-- index -->
|
||||
<argument type="service" id="doctrine.orm.entity_manager" />
|
||||
<argument /> <!-- transformer -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue