Move doctrine related logic to Doctrine\ORM and Doctrine\MongoDB

This commit is contained in:
ornicar 2011-05-09 15:31:20 -07:00
parent 30eb9c90f5
commit 1eff840c99
9 changed files with 25 additions and 18 deletions

View file

@ -1,7 +1,8 @@
<?php <?php
namespace FOQ\ElasticaBundle\Transformer; namespace FOQ\ElasticaBundle\Doctrine;
use FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
use Elastica_Document; use Elastica_Document;
/** /**
@ -9,7 +10,7 @@ use Elastica_Document;
* This mapper assumes an exact match between * This mapper assumes an exact match between
* elastica documents ids and doctrine object ids * elastica documents ids and doctrine object ids
*/ */
abstract class ElasticaToModelAbstractDoctrineTransformer implements ElasticaToModelTransformerInterface abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTransformerInterface
{ {
/** /**
* Repository to fetch the objects from * Repository to fetch the objects from

View file

@ -1,14 +1,15 @@
<?php <?php
namespace FOQ\ElasticaBundle\Provider; namespace FOQ\ElasticaBundle\Doctrine;
use FOQ\ElasticaBundle\Provider\ProviderInterface;
use FOQ\ElasticaBundle\Transformer\ModelToElasticaTransformerInterface; use FOQ\ElasticaBundle\Transformer\ModelToElasticaTransformerInterface;
use Elastica_Type; use Elastica_Type;
use Elastica_Document; use Elastica_Document;
use Closure; use Closure;
use InvalidArgumentException; use InvalidArgumentException;
abstract class AbstractDoctrineProvider implements ProviderInterface abstract class AbstractProvider implements ProviderInterface
{ {
protected $type; protected $type;
protected $objectManager; protected $objectManager;

View file

@ -1,7 +1,8 @@
<?php <?php
namespace FOQ\ElasticaBundle\Transformer; namespace FOQ\ElasticaBundle\Doctrine\MongoDB;
use FOQ\ElasticaBundle\Doctrine\AbstractElasticaToModelTransformer;
use Elastica_Document; use Elastica_Document;
/** /**
@ -9,7 +10,7 @@ use Elastica_Document;
* This mapper assumes an exact match between * This mapper assumes an exact match between
* elastica documents ids and doctrine object ids * elastica documents ids and doctrine object ids
*/ */
class ElasticaToModelDoctrineMongoDBTransformer extends ElasticaToModelAbstractDoctrineTransformer class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
{ {
/** /**
* Fetch objects for theses identifier values * Fetch objects for theses identifier values

View file

@ -1,8 +1,10 @@
<?php <?php
namespace FOQ\ElasticaBundle\Provider; namespace FOQ\ElasticaBundle\Doctrine\MongoDB;
class DoctrineMongoDBProvider extends AbstractDoctrineProvider use FOQ\ElasticaBundle\Doctrine\AbstractProvider;
class Provider extends AbstractProvider
{ {
/** /**
* Counts the objects of a query builder * Counts the objects of a query builder

View file

@ -1,6 +1,6 @@
<?php <?php
namespace FOQ\ElasticaBundle\Transformer; namespace FOQ\ElasticaBundle\Doctrine\ORM;
use Elastica_Document; use Elastica_Document;
@ -9,7 +9,7 @@ use Elastica_Document;
* This mapper assumes an exact match between * This mapper assumes an exact match between
* elastica documents ids and doctrine object ids * elastica documents ids and doctrine object ids
*/ */
class ElasticaToModelDoctrineORMTransformer extends ElasticaToModelAbstractDoctrineTransformer class ElasticaToModelTransformer extends AbstractElasticaToModelTransformer
{ {
/** /**
* Fetch objects for theses identifier values * Fetch objects for theses identifier values

View file

@ -1,8 +1,10 @@
<?php <?php
namespace FOQ\ElasticaBundle\Provider; namespace FOQ\ElasticaBundle\Doctrine\ORM;
class DoctrineORMProvider extends AbstractDoctrineProvider use FOQ\ElasticaBundle\Doctrine\AbstractProvider;
class Provider extends AbstractProvider
{ {
/** /**
* Counts the objects of a query builder * Counts the objects of a query builder

View file

@ -1,6 +1,6 @@
<?php <?php
namespace FOQ\ElasticaBundle\Paginator; namespace FOQ\ElasticaBundle\Doctrine;
use FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface; use FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface;
use Elastica_Searchable; use Elastica_Searchable;
@ -11,7 +11,7 @@ use Elastica_Query;
* *
* Allows pagination of Elastica_Query * Allows pagination of Elastica_Query
*/ */
class DoctrinePaginatorAdapter extends AbstractPaginatorAdapter class PaginatorAdapter extends AbstractPaginatorAdapter
{ {
protected $transformer; protected $transformer;

View file

@ -6,7 +6,7 @@
<services> <services>
<service id="foq_elastica.provider.prototype.mongodb" class="FOQ\ElasticaBundle\Provider\DoctrineMongoDBProvider" public="false" abstract="true"> <service id="foq_elastica.provider.prototype.mongodb" class="FOQ\ElasticaBundle\Doctrine\MongoDB\Provider" public="false" abstract="true">
<argument /> <!-- index --> <argument /> <!-- index -->
<argument type="service" id="doctrine.odm.mongodb.document_manager" /> <argument type="service" id="doctrine.odm.mongodb.document_manager" />
<argument /> <!-- transformer --> <argument /> <!-- transformer -->
@ -14,7 +14,7 @@
<argument type="collection" /> <!-- options --> <argument type="collection" /> <!-- options -->
</service> </service>
<service id="foq_elastica.elastica_to_model_transformer.prototype.mongodb" class="FOQ\ElasticaBundle\Transformer\ElasticaToModelDoctrineMongoDBTransformer" public="false"> <service id="foq_elastica.elastica_to_model_transformer.prototype.mongodb" class="FOQ\ElasticaBundle\Doctrine\MongoDB\ElasticaToModelTransformer" public="false">
<argument type="service" id="doctrine.odm.mongodb.document_manager" /> <argument type="service" id="doctrine.odm.mongodb.document_manager" />
<argument /> <!-- model --> <argument /> <!-- model -->
<argument type="collection" /> <!-- options --> <argument type="collection" /> <!-- options -->

View file

@ -6,7 +6,7 @@
<services> <services>
<service id="foq_elastica.provider.prototype.orm" class="FOQ\ElasticaBundle\Provider\DoctrineORMProvider" public="false" abstract="true"> <service id="foq_elastica.provider.prototype.orm" class="FOQ\ElasticaBundle\Doctrine\ORM\Provider" public="false" abstract="true">
<argument /> <!-- index --> <argument /> <!-- index -->
<argument type="service" id="doctrine.orm.entity_manager" /> <argument type="service" id="doctrine.orm.entity_manager" />
<argument /> <!-- transformer --> <argument /> <!-- transformer -->
@ -14,7 +14,7 @@
<argument type="collection" /> <!-- options --> <argument type="collection" /> <!-- options -->
</service> </service>
<service id="foq_elastica.elastica_to_model_transformer.prototype.orm" class="FOQ\ElasticaBundle\Transformer\ElasticaToModelDoctrineTransformer" public="false"> <service id="foq_elastica.elastica_to_model_transformer.prototype.orm" class="FOQ\ElasticaBundle\Doctrine\ORM\Transformer" public="false">
<argument type="service" id="doctrine.orm.entity_manager" /> <argument type="service" id="doctrine.orm.entity_manager" />
<argument /> <!-- model --> <argument /> <!-- model -->
<argument type="collection" /> <!-- options --> <argument type="collection" /> <!-- options -->