diff --git a/Client.php b/Client.php index fe700ad..b1a9cc5 100644 --- a/Client.php +++ b/Client.php @@ -1,9 +1,9 @@ diff --git a/Command/PopulateCommand.php b/Command/PopulateCommand.php index 4e7a9fe..dba5a87 100755 --- a/Command/PopulateCommand.php +++ b/Command/PopulateCommand.php @@ -1,6 +1,6 @@ setName('foq:elastica:populate') + ->setName('fos:elastica:populate') ->setDescription('Populates search indexes from providers') ->addOption('no-reset', null, InputOption::VALUE_NONE, 'Do not reset the indexes before they are populated.'); } @@ -32,18 +32,18 @@ class PopulateCommand extends ContainerAwareCommand { if (!$input->getOption('no-reset')) { $output->writeln('Resetting indexes'); - $this->getContainer()->get('foq_elastica.reseter')->reset(); + $this->getContainer()->get('fos_elastica.reseter')->reset(); } $output->writeln('Populating indexes'); - $this->getContainer()->get('foq_elastica.populator')->populate(function($text) use ($output) { + $this->getContainer()->get('fos_elastica.populator')->populate(function($text) use ($output) { $output->writeLn($text); }); $output->writeln('Refreshing indexes'); array_map(function($index) { $index->refresh(); - }, $this->getContainer()->get('foq_elastica.index_manager')->getAllIndexes()); + }, $this->getContainer()->get('fos_elastica.index_manager')->getAllIndexes()); $output->writeln('Done'); } diff --git a/Command/SearchCommand.php b/Command/SearchCommand.php index 27b7e93..17f6045 100644 --- a/Command/SearchCommand.php +++ b/Command/SearchCommand.php @@ -1,6 +1,6 @@ addOption('show-source', null, InputOption::VALUE_NONE, 'Show the documents sources') ->addOption('show-id', null, InputOption::VALUE_NONE, 'Show the documents ids') ->addOption('explain', null, InputOption::VALUE_NONE, 'Enables explanation for each hit on how its score was computed.') - ->setName('foq:elastica:search') + ->setName('fos:elastica:search') ->setDescription('Searches documents in a given type and index'); } @@ -41,7 +41,7 @@ class SearchCommand extends ContainerAwareCommand */ protected function execute(InputInterface $input, OutputInterface $output) { - $index = $this->getContainer()->get('foq_elastica.index_manager')->getIndex($input->getOption('index')); + $index = $this->getContainer()->get('fos_elastica.index_manager')->getIndex($input->getOption('index')); $type = $index->getType($input->getArgument('type')); $query = Elastica_Query::create($input->getArgument('query')); $query->setLimit($input->getOption('limit')); diff --git a/Configuration/Search.php b/Configuration/Search.php index d3cb624..ded65a5 100644 --- a/Configuration/Search.php +++ b/Configuration/Search.php @@ -1,6 +1,6 @@ hasDefinition('foq_elastica.populator')) { + if (!$container->hasDefinition('fos_elastica.populator')) { return; } $providers = array(); - foreach ($container->findTaggedServiceIds('foq_elastica.provider') as $id => $attributes) { + foreach ($container->findTaggedServiceIds('fos_elastica.provider') as $id => $attributes) { $providers[$id] = new Reference($id); } - $container->getDefinition('foq_elastica.populator')->replaceArgument(0, $providers); + $container->getDefinition('fos_elastica.populator')->replaceArgument(0, $providers); } } diff --git a/DependencyInjection/Compiler/TransformerPass.php b/DependencyInjection/Compiler/TransformerPass.php index ea7bc85..2c260c9 100644 --- a/DependencyInjection/Compiler/TransformerPass.php +++ b/DependencyInjection/Compiler/TransformerPass.php @@ -1,6 +1,6 @@ hasDefinition('foq_elastica.elastica_to_model_transformer.collection.prototype')) { + if (!$container->hasDefinition('fos_elastica.elastica_to_model_transformer.collection.prototype')) { return; } $transformers = array(); - foreach ($container->findTaggedServiceIds('foq_elastica.elastica_to_model_transformer') as $id => $tags) { + foreach ($container->findTaggedServiceIds('fos_elastica.elastica_to_model_transformer') as $id => $tags) { foreach ($tags as $tag) { if (empty($tag['index']) || empty($tag['type'])) { throw new InvalidArgumentException('The Transformer must have both a type and an index defined.'); @@ -37,11 +37,11 @@ class TransformerPass implements CompilerPassInterface } foreach ($transformers as $index => $indexTransformers) { - if (!$container->hasDefinition(sprintf('foq_elastica.elastica_to_model_transformer.collection.%s', $index))) { + if (!$container->hasDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index))) { continue; } - $index = $container->getDefinition(sprintf('foq_elastica.elastica_to_model_transformer.collection.%s', $index)); + $index = $container->getDefinition(sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $index)); $index->replaceArgument(0, $indexTransformers); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7348a47..187d6b0 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,6 +1,6 @@ root('foq_elastica', 'array'); + $rootNode = $treeBuilder->root('fos_elastica', 'array'); $this->addClientsSection($rootNode); $this->addIndexesSection($rootNode); diff --git a/DependencyInjection/FOQElasticaExtension.php b/DependencyInjection/FOQElasticaExtension.php index a82e47b..9ae1bda 100644 --- a/DependencyInjection/FOQElasticaExtension.php +++ b/DependencyInjection/FOQElasticaExtension.php @@ -1,6 +1,6 @@ loadIndexManager($indexDefsByName, $container->getDefinition($indexIdsByName[$config['default_index']]), $container); $this->loadReseter($this->indexConfigs, $container); - $container->setAlias('foq_elastica.client', sprintf('foq_elastica.client.%s', $config['default_client'])); - $container->setAlias('foq_elastica.index', sprintf('foq_elastica.index.%s', $config['default_index'])); + $container->setAlias('fos_elastica.client', sprintf('fos_elastica.client.%s', $config['default_client'])); + $container->setAlias('fos_elastica.index', sprintf('fos_elastica.index.%s', $config['default_index'])); $this->createDefaultManagerAlias($config['default_manager'], $container); } @@ -66,10 +66,10 @@ class FOQElasticaExtension extends Extension { $clientIds = array(); foreach ($clients as $name => $clientConfig) { - $clientDef = $container->getDefinition('foq_elastica.client'); + $clientDef = $container->getDefinition('fos_elastica.client'); $clientDef->replaceArgument(0, $clientConfig); - $clientId = sprintf('foq_elastica.client.%s', $name); + $clientId = sprintf('fos_elastica.client.%s', $name); $container->setDefinition($clientId, $clientDef); @@ -99,9 +99,9 @@ class FOQElasticaExtension extends Extension } $clientId = $clientIdsByName[$clientName]; - $indexId = sprintf('foq_elastica.index.%s', $name); + $indexId = sprintf('fos_elastica.index.%s', $name); $indexDefArgs = array($name); - $indexDef = new Definition('%foq_elastica.index.class%', $indexDefArgs); + $indexDef = new Definition('%fos_elastica.index.class%', $indexDefArgs); $indexDef->setFactoryService($clientId); $indexDef->setFactoryMethod('getIndex'); $container->setDefinition($indexId, $indexDef); @@ -135,13 +135,13 @@ class FOQElasticaExtension extends Extension */ protected function loadIndexFinder(ContainerBuilder $container, $name, $indexId) { - $abstractTransformerId = 'foq_elastica.elastica_to_model_transformer.collection.prototype'; - $transformerId = sprintf('foq_elastica.elastica_to_model_transformer.collection.%s', $name); + $abstractTransformerId = 'fos_elastica.elastica_to_model_transformer.collection.prototype'; + $transformerId = sprintf('fos_elastica.elastica_to_model_transformer.collection.%s', $name); $transformerDef = new DefinitionDecorator($abstractTransformerId); $container->setDefinition($transformerId, $transformerDef); - $abstractFinderId = 'foq_elastica.finder.prototype'; - $finderId = sprintf('foq_elastica.finder.%s', $name); + $abstractFinderId = 'fos_elastica.finder.prototype'; + $finderId = sprintf('fos_elastica.finder.%s', $name); $finderDef = new DefinitionDecorator($abstractFinderId); $finderDef->replaceArgument(0, new Reference($indexId)); $finderDef->replaceArgument(1, new Reference($transformerId)); @@ -163,7 +163,7 @@ class FOQElasticaExtension extends Extension $type = self::deepArrayUnion($typePrototypeConfig, $type); $typeId = sprintf('%s.%s', $indexId, $name); $typeDefArgs = array($name); - $typeDef = new Definition('%foq_elastica.type.class%', $typeDefArgs); + $typeDef = new Definition('%fos_elastica.type.class%', $typeDefArgs); $typeDef->setFactoryService($indexId); $typeDef->setFactoryMethod('getType'); $container->setDefinition($typeId, $typeDef); @@ -217,7 +217,7 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['provider'])) { $providerId = $this->loadTypeProvider($typeConfig, $container, $objectPersisterId, $typeDef, $indexName, $typeName); - $container->getDefinition('foq_elastica.populator')->addMethodCall('addProvider', array($providerId, new Reference($providerId))); + $container->getDefinition('fos_elastica.populator')->addMethodCall('addProvider', array($providerId, new Reference($providerId))); } if (isset($typeConfig['finder'])) { $this->loadTypeFinder($typeConfig, $container, $elasticaToModelTransformerId, $typeDef, $indexName, $typeName); @@ -232,10 +232,10 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['elastica_to_model_transformer']['service'])) { return $typeConfig['elastica_to_model_transformer']['service']; } - $abstractId = sprintf('foq_elastica.elastica_to_model_transformer.prototype.%s', $typeConfig['driver']); - $serviceId = sprintf('foq_elastica.elastica_to_model_transformer.%s.%s', $indexName, $typeName); + $abstractId = sprintf('fos_elastica.elastica_to_model_transformer.prototype.%s', $typeConfig['driver']); + $serviceId = sprintf('fos_elastica.elastica_to_model_transformer.%s.%s', $indexName, $typeName); $serviceDef = new DefinitionDecorator($abstractId); - $serviceDef->addTag('foq_elastica.elastica_to_model_transformer', array('type' => $typeName, 'index' => $indexName)); + $serviceDef->addTag('fos_elastica.elastica_to_model_transformer', array('type' => $typeName, 'index' => $indexName)); // Doctrine has a mandatory service as first argument $argPos = ('propel' === $typeConfig['driver']) ? 0 : 1; @@ -255,8 +255,8 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['model_to_elastica_transformer']['service'])) { return $typeConfig['model_to_elastica_transformer']['service']; } - $abstractId = sprintf('foq_elastica.model_to_elastica_transformer.prototype.auto'); - $serviceId = sprintf('foq_elastica.model_to_elastica_transformer.%s.%s', $indexName, $typeName); + $abstractId = sprintf('fos_elastica.model_to_elastica_transformer.prototype.auto'); + $serviceId = sprintf('fos_elastica.model_to_elastica_transformer.%s.%s', $indexName, $typeName); $serviceDef = new DefinitionDecorator($abstractId); $serviceDef->replaceArgument(0, array( 'identifier' => $typeConfig['identifier'] @@ -268,8 +268,8 @@ class FOQElasticaExtension extends Extension protected function loadObjectPersister(array $typeConfig, Definition $typeDef, ContainerBuilder $container, $indexName, $typeName, $transformerId) { - $abstractId = sprintf('foq_elastica.object_persister.prototype'); - $serviceId = sprintf('foq_elastica.object_persister.%s.%s', $indexName, $typeName); + $abstractId = sprintf('fos_elastica.object_persister.prototype'); + $serviceId = sprintf('fos_elastica.object_persister.%s.%s', $indexName, $typeName); $serviceDef = new DefinitionDecorator($abstractId); $serviceDef->replaceArgument(0, $typeDef); $serviceDef->replaceArgument(1, new Reference($transformerId)); @@ -285,8 +285,8 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['provider']['service'])) { return $typeConfig['provider']['service']; } - $abstractProviderId = sprintf('foq_elastica.provider.prototype.%s', $typeConfig['driver']); - $providerId = sprintf('foq_elastica.provider.%s.%s', $indexName, $typeName); + $abstractProviderId = sprintf('fos_elastica.provider.prototype.%s', $typeConfig['driver']); + $providerId = sprintf('fos_elastica.provider.%s.%s', $indexName, $typeName); $providerDef = new DefinitionDecorator($abstractProviderId); $providerDef->replaceArgument(0, $typeDef); @@ -314,8 +314,8 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['listener']['service'])) { return $typeConfig['listener']['service']; } - $abstractListenerId = sprintf('foq_elastica.listener.prototype.%s', $typeConfig['driver']); - $listenerId = sprintf('foq_elastica.listener.%s.%s', $indexName, $typeName); + $abstractListenerId = sprintf('fos_elastica.listener.prototype.%s', $typeConfig['driver']); + $listenerId = sprintf('fos_elastica.listener.%s.%s', $indexName, $typeName); $listenerDef = new DefinitionDecorator($abstractListenerId); $listenerDef->replaceArgument(0, new Reference($objectPersisterId)); $listenerDef->replaceArgument(1, $typeConfig['model']); @@ -353,14 +353,14 @@ class FOQElasticaExtension extends Extension if (isset($typeConfig['finder']['service'])) { return $typeConfig['finder']['service']; } - $abstractFinderId = 'foq_elastica.finder.prototype'; - $finderId = sprintf('foq_elastica.finder.%s.%s', $indexName, $typeName); + $abstractFinderId = 'fos_elastica.finder.prototype'; + $finderId = sprintf('fos_elastica.finder.%s.%s', $indexName, $typeName); $finderDef = new DefinitionDecorator($abstractFinderId); $finderDef->replaceArgument(0, $typeDef); $finderDef->replaceArgument(1, new Reference($elasticaToModelId)); $container->setDefinition($finderId, $finderDef); - $managerId = sprintf('foq_elastica.manager.%s', $typeConfig['driver']); + $managerId = sprintf('fos_elastica.manager.%s', $typeConfig['driver']); $managerDef = $container->getDefinition($managerId); $arguments = array( $typeConfig['model'], new Reference($finderId)); if (isset($typeConfig['repository'])) { @@ -379,9 +379,9 @@ class FOQElasticaExtension extends Extension **/ protected function loadIndexManager(array $indexDefs, $defaultIndexId, ContainerBuilder $container) { - $managerDef = $container->getDefinition('foq_elastica.index_manager'); + $managerDef = $container->getDefinition('fos_elastica.index_manager'); $managerDef->replaceArgument(0, $indexDefs); - $managerDef->replaceArgument(1, new Reference('foq_elastica.index')); + $managerDef->replaceArgument(1, new Reference('fos_elastica.index')); } /** @@ -391,7 +391,7 @@ class FOQElasticaExtension extends Extension **/ protected function loadReseter(array $indexConfigs, ContainerBuilder $container) { - $reseterDef = $container->getDefinition('foq_elastica.reseter'); + $reseterDef = $container->getDefinition('fos_elastica.reseter'); $reseterDef->replaceArgument(0, $indexConfigs); } @@ -419,7 +419,7 @@ class FOQElasticaExtension extends Extension $defaultManagerService = $this->loadedDrivers[0]; } - $container->setAlias('foq_elastica.manager', sprintf('foq_elastica.manager.%s', $defaultManagerService)); + $container->setAlias('fos_elastica.manager', sprintf('fos_elastica.manager.%s', $defaultManagerService)); } } diff --git a/Doctrine/AbstractElasticaToModelTransformer.php b/Doctrine/AbstractElasticaToModelTransformer.php index df14d00..f97e70d 100755 --- a/Doctrine/AbstractElasticaToModelTransformer.php +++ b/Doctrine/AbstractElasticaToModelTransformer.php @@ -1,10 +1,10 @@ @@ -58,14 +58,14 @@ class RepositoryManager implements RepositoryManagerInterface } $refClass = new \ReflectionClass($entityName); - $annotation = $this->reader->getClassAnnotation($refClass, 'FOQ\\ElasticaBundle\\Configuration\\Search'); + $annotation = $this->reader->getClassAnnotation($refClass, 'FOS\\ElasticaBundle\\Configuration\\Search'); if ($annotation) { $this->entities[$entityName]['repositoryName'] = $annotation->repositoryClass; return $annotation->repositoryClass; } - return 'FOQ\ElasticaBundle\Repository'; + return 'FOS\ElasticaBundle\Repository'; } private function createRepository($entityName) diff --git a/Manager/RepositoryManagerInterface.php b/Manager/RepositoryManagerInterface.php index 9340506..c831d35 100644 --- a/Manager/RepositoryManagerInterface.php +++ b/Manager/RepositoryManagerInterface.php @@ -1,8 +1,8 @@ diff --git a/MappingRegistry.php b/MappingRegistry.php index 3573e9f..c3d7bb9 100644 --- a/MappingRegistry.php +++ b/MappingRegistry.php @@ -1,6 +1,6 @@ registerNamespaces(array( ... - 'FOQ' => __DIR__.'/../vendor/bundles', + 'FOS' => __DIR__.'/../vendor/bundles', )); #### Register the bundle @@ -86,7 +86,7 @@ $ php bin/vendors install { return array( // ... - new FOQ\ElasticaBundle\FOQElasticaBundle(), + new FOS\ElasticaBundle\FOSElasticaBundle(), // ... ); } @@ -99,7 +99,7 @@ Elasticsearch client is comparable to a database connection. Most of the time, you will need only one. #app/config/config.yml - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } @@ -108,7 +108,7 @@ Most of the time, you will need only one. Elasticsearch index is comparable to Doctrine entity manager. Most of the time, you will need only one. - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -117,13 +117,13 @@ Most of the time, you will need only one. Here we created a "website" index, that uses our "default" client. -Our index is now available as a service: `foq_elastica.index.website`. It is an instance of `Elastica_Index`. +Our index is now available as a service: `fos_elastica.index.website`. It is an instance of `Elastica_Index`. #### Declare a type Elasticsearch type is comparable to Doctrine entity repository. - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -137,11 +137,11 @@ Elasticsearch type is comparable to Doctrine entity repository. lastName: { boost: 3 } aboutMe: -Our type is now available as a service: `foq_elastica.index.website.user`. It is an instance of `Elastica_Type`. +Our type is now available as a service: `fos_elastica.index.website.user`. It is an instance of `Elastica_Type`. ### Populate the types - php app/console foq:elastica:populate + php app/console fos:elastica:populate This command deletes and creates the declared indexes and types. It applies the configured mappings to the types. @@ -156,7 +156,7 @@ Or, for complete flexibility, go for manual provider. If we want to index the entities from a Doctrine repository or a Propel query, some configuration will let ElasticaBundle do it for us. - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -213,20 +213,20 @@ You can change this value in the provider configuration. #### Manual provider -Create a service with the tag "foq_elastica.provider". +Create a service with the tag "fos_elastica.provider". - - + + -Its class must implement `FOQ\ElasticaBundle\Provider\ProviderInterface`. +Its class must implement `FOS\ElasticaBundle\Provider\ProviderInterface`. container->get('foq_elastica.index.website.user'); + $userType = $this->container->get('fos_elastica.index.website.user'); /** var Elastica_ResultSet */ $resultSet = $userType->search('bob'); @@ -271,7 +271,7 @@ If your elasticsearch type is bound to a Doctrine entity repository or a Propel you can get your entities instead of Elastica results when you perform a search. Declare that you want a Doctrine/Propel finder in your configuration: - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -287,10 +287,10 @@ Declare that you want a Doctrine/Propel finder in your configuration: provider: finder: -You can now use the `foq_elastica.finder.website.user` service: +You can now use the `fos_elastica.finder.website.user` service: - /** var FOQ\ElasticaBundle\Finder\TransformedFinder */ - $finder = $container->get('foq_elastica.finder.website.user'); + /** var FOS\ElasticaBundle\Finder\TransformedFinder */ + $finder = $container->get('fos_elastica.finder.website.user'); /** var array of Acme\UserBundle\Entity\User */ $users = $finder->find('bob'); @@ -307,7 +307,7 @@ You can also get both the Elastica results and the entities together from the fi YOu can then access the score, highlights etc. from the Elastica_Result whilst still also getting the entity. - /** var array of FOQ\ElasticaBundle\HybridResult */ + /** var array of FOS\ElasticaBundle\HybridResult */ $hybridResults = $finder->findHybrid('bob'); foreach ($hybridResults as $hybridResult) { @@ -324,16 +324,16 @@ still also getting the entity. You can also define a finder that will work on the entire index. Adjust your index configuration as per below: - foq_elastica: + fos_elastica: indexes: website: client: default finder: -You can now use the index wide finder service `foq_elastica.finder.website`: +You can now use the index wide finder service `fos_elastica.finder.website`: - /** var FOQ\ElasticaBundle\Finder\MappedFinder */ - $finder = $container->get('foq_elastica.finder.website'); + /** var FOS\ElasticaBundle\Finder\MappedFinder */ + $finder = $container->get('fos_elastica.finder.website'); // Returns a mixed array of any objects mapped $results = $finder->find('bob'); @@ -345,10 +345,10 @@ can use a manager service for each driver and get a repository for an entity to against. This allows you to use the same service rather than the particular finder. For example: - /** var FOQ\ElasticaBundle\Manager\RepositoryManager */ - $repositoryManager = $container->get('foq_elastica.manager.orm'); + /** var FOS\ElasticaBundle\Manager\RepositoryManager */ + $repositoryManager = $container->get('fos_elastica.manager.orm'); - /** var FOQ\ElasticaBundle\Repository */ + /** var FOS\ElasticaBundle\Repository */ $repository = $repositoryManager->getRepository('UserBundle:User'); /** var array of Acme\UserBundle\Entity\User */ @@ -356,7 +356,7 @@ example: You can also specify the full name of the entity instead of the shortcut syntax: - /** var FOQ\ElasticaBundle\Repository */ + /** var FOS\ElasticaBundle\Repository */ $repository = $repositoryManager->getRepository('Application\UserBundle\Entity\User'); > The **2.0** branch doesn't support using `UserBundle:User` style syntax and you must use the full name of the entity. . @@ -364,21 +364,21 @@ You can also specify the full name of the entity instead of the shortcut syntax: ##### Default Manager If you are only using one driver then its manager service is automatically aliased -to `foq_elastica.manager`. So the above example could be simplified to: +to `fos_elastica.manager`. So the above example could be simplified to: - /** var FOQ\ElasticaBundle\Manager\RepositoryManager */ - $repositoryManager = $container->get('foq_elastica.manager'); + /** var FOS\ElasticaBundle\Manager\RepositoryManager */ + $repositoryManager = $container->get('fos_elastica.manager'); - /** var FOQ\ElasticaBundle\Repository */ + /** var FOS\ElasticaBundle\Repository */ $repository = $repositoryManager->getRepository('UserBundle:User'); /** var array of Acme\UserBundle\Entity\User */ $users = $finder->find('bob'); -If you use multiple drivers then you can choose which one is aliased to `foq_elastica.manager` +If you use multiple drivers then you can choose which one is aliased to `fos_elastica.manager` using the `default_manager` parameter: - foq_elastica: + fos_elastica: default_manager: mongodb #defauults to orm clients: default: { host: localhost, port: 9200 } @@ -387,7 +387,7 @@ using the `default_manager` parameter: ##### Custom Repositories As well as the default repository you can create a custom repository for an entity and add -methods for particular searches. These need to extend `FOQ\ElasticaBundle\Repository` to have +methods for particular searches. These need to extend `FOS\ElasticaBundle\Repository` to have access to the finder: ``` @@ -395,7 +395,7 @@ access to the finder: namespace Acme\ElasticaBundle\SearchRepository; -use FOQ\ElasticaBundle\Repository; +use FOS\ElasticaBundle\Repository; class UserRepository extends Repository { @@ -409,7 +409,7 @@ class UserRepository extends Repository To use the custom repository specify it in the mapping for the entity: - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -428,10 +428,10 @@ To use the custom repository specify it in the mapping for the entity: Then the custom queries will be available when using the repository returned from the manager: - /** var FOQ\ElasticaBundle\Manager\RepositoryManager */ - $repositoryManager = $container->get('foq_elastica.manager'); + /** var FOS\ElasticaBundle\Manager\RepositoryManager */ + $repositoryManager = $container->get('fos_elastica.manager'); - /** var FOQ\ElasticaBundle\Repository */ + /** var FOS\ElasticaBundle\Repository */ $repository = $repositoryManager->getRepository('UserBundle:User'); /** var array of Acme\UserBundle\Entity\User */ @@ -444,7 +444,7 @@ Alternatively you can specify the custom repository using an annotation in the e namespace Application\UserBundle\Entity; -use FOQ\ElasticaBundle\Configuration\Search; +use FOS\ElasticaBundle\Configuration\Search; /** * @Search(repositoryClass="Acme\ElasticaBundle\SearchRepository\UserRepository") @@ -463,7 +463,7 @@ If you use the Doctrine integration, you can let ElasticaBundle update the index when an object is added, updated or removed. It uses Doctrine lifecycle events. Declare that you want to update the index in real time: - foq_elastica: + fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: @@ -495,7 +495,7 @@ You can also choose to only listen for some of the events: Any setting can be specified when declaring a type. For example, to enable a custom analyzer, you could write: - foq_elastica: + fos_elastica: indexes: doc: settings: @@ -524,7 +524,7 @@ issuing a request will result in an `Elastica_Exception_Client` being thrown. Depending on your needs, it may be desirable to suppress these exceptions and allow searches to fail silently. -One way to achieve this is to override the `foq_elastica.client.class` service +One way to achieve this is to override the `fos_elastica.client.class` service container parameter with a custom class. In the following example, we override the `Client::request()` method and return the equivalent of an empty search response if an exception occurred. @@ -534,7 +534,7 @@ response if an exception occurred. namespace Acme\ElasticaBundle; -use FOQ\ElasticaBundle\Client as BaseClient; +use FOS\ElasticaBundle\Client as BaseClient; class Client extends BaseClient { @@ -560,7 +560,7 @@ Results must match at least one specified `categoryIds`, and should match the apply to queries against the `title` field. ```php -$finder = $this->container->get('foq_elastica.finder.website.article'); +$finder = $this->container->get('fos_elastica.finder.website.article'); $boolQuery = new \Elastica_Query_Bool(); $fieldQuery = new \Elastica_Query_Text(); @@ -582,7 +582,7 @@ $data = $finder->find($boolQuery); Configuration: ```yaml -foq_elastica: +fos_elastica: clients: default: { host: localhost, port: 9200 } indexes: diff --git a/Repository.php b/Repository.php index 63eea71..5e7589b 100644 --- a/Repository.php +++ b/Repository.php @@ -1,6 +1,6 @@ diff --git a/Reseter.php b/Reseter.php index 98a7ee0..6a099b0 100644 --- a/Reseter.php +++ b/Reseter.php @@ -1,6 +1,6 @@ - FOQ\ElasticaBundle\Client - Elastica_Index - Elastica_Type - FOQ\ElasticaBundle\Logger\ElasticaLogger - FOQ\ElasticaBundle\DataCollector\ElasticaDataCollector - FOQ\ElasticaBundle\Manager\RepositoryManager - FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerCollection + FOS\ElasticaBundle\Client + Elastica_Index + Elastica_Type + FOS\ElasticaBundle\Logger\ElasticaLogger + FOS\ElasticaBundle\DataCollector\ElasticaDataCollector + FOS\ElasticaBundle\Manager\RepositoryManager + FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerCollection - + %kernel.debug% - - - + + + - + - + - + - + - + - + - + - + - + diff --git a/Resources/config/mongodb.xml b/Resources/config/mongodb.xml index af24531..913849c 100644 --- a/Resources/config/mongodb.xml +++ b/Resources/config/mongodb.xml @@ -6,7 +6,7 @@ - + @@ -14,20 +14,20 @@ - + - + - + diff --git a/Resources/config/orm.xml b/Resources/config/orm.xml index 71fa2aa..937ec3f 100644 --- a/Resources/config/orm.xml +++ b/Resources/config/orm.xml @@ -6,7 +6,7 @@ - + @@ -14,20 +14,20 @@ - + - + - + diff --git a/Resources/config/propel.xml b/Resources/config/propel.xml index 39c7a31..0ac3876 100644 --- a/Resources/config/propel.xml +++ b/Resources/config/propel.xml @@ -5,19 +5,19 @@ - + - + - + diff --git a/Resources/views/Collector/elastica.html.twig b/Resources/views/Collector/elastica.html.twig index e6fc29c..31e36eb 100644 --- a/Resources/views/Collector/elastica.html.twig +++ b/Resources/views/Collector/elastica.html.twig @@ -12,7 +12,7 @@ {% block menu %} - + Elastica {{ collector.querycount }} diff --git a/Tests/DataCollector/ElasticaDataCollectorTest.php b/Tests/DataCollector/ElasticaDataCollectorTest.php index b83a81c..737db49 100644 --- a/Tests/DataCollector/ElasticaDataCollectorTest.php +++ b/Tests/DataCollector/ElasticaDataCollectorTest.php @@ -1,8 +1,8 @@ @@ -20,7 +20,7 @@ class ElasticaDataCollectorTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $loggerMock = $this->getMockBuilder('FOQ\ElasticaBundle\Logger\ElasticaLogger') + $loggerMock = $this->getMockBuilder('FOS\ElasticaBundle\Logger\ElasticaLogger') ->disableOriginalConstructor() ->getMock(); @@ -45,7 +45,7 @@ class ElasticaDataCollectorTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $loggerMock = $this->getMockBuilder('FOQ\ElasticaBundle\Logger\ElasticaLogger') + $loggerMock = $this->getMockBuilder('FOS\ElasticaBundle\Logger\ElasticaLogger') ->disableOriginalConstructor() ->getMock(); diff --git a/Tests/Doctrine/MongoDB/ListenerTest.php b/Tests/Doctrine/MongoDB/ListenerTest.php index c2f94a5..896af35 100644 --- a/Tests/Doctrine/MongoDB/ListenerTest.php +++ b/Tests/Doctrine/MongoDB/ListenerTest.php @@ -1,8 +1,8 @@ getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -28,7 +28,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; $document = new Document(); $eventArgsMock->expects($this->once()) @@ -45,7 +45,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectReplacedOnUpdate() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -53,7 +53,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; $document = new Document(); $eventArgsMock->expects($this->once()) @@ -70,7 +70,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectDeletedOnRemove() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -86,7 +86,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; $document = new Document(); $documentId = 78; @@ -118,7 +118,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectWithNonStandardIdentifierDeletedOnRemove() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -134,7 +134,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\MongoDB\Document'; $document = new Document(); $documentIdentifier = 826; $identifierField = 'identifier'; diff --git a/Tests/Doctrine/ORM/ListenerTest.php b/Tests/Doctrine/ORM/ListenerTest.php index 6afdec8..905c5fe 100644 --- a/Tests/Doctrine/ORM/ListenerTest.php +++ b/Tests/Doctrine/ORM/ListenerTest.php @@ -1,8 +1,8 @@ getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -28,7 +28,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\ORM\Entity'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\ORM\Entity'; $entity = new Entity; $eventArgsMock->expects($this->once()) @@ -45,7 +45,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectReplacedOnUpdate() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -53,7 +53,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\ORM\Entity'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\ORM\Entity'; $entity = new Entity; $eventArgsMock->expects($this->once()) @@ -70,7 +70,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectDeletedOnRemove() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -86,7 +86,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\ORM\Entity'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\ORM\Entity'; $entity = new Entity; $entityId = 21; @@ -118,7 +118,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase public function testObjectWithNonStandardIdentifierDeletedOnRemove() { - $persisterMock = $this->getMockBuilder('FOQ\ElasticaBundle\Persister\ObjectPersisterInterface') + $persisterMock = $this->getMockBuilder('FOS\ElasticaBundle\Persister\ObjectPersisterInterface') ->disableOriginalConstructor() ->getMock(); @@ -134,7 +134,7 @@ class ListenerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $objectName = 'FOQ\ElasticaBundle\Tests\Doctrine\ORM\Entity'; + $objectName = 'FOS\ElasticaBundle\Tests\Doctrine\ORM\Entity'; $entity = new Entity; $entityIdentifier = 924; $identifierField = 'identifier'; diff --git a/Tests/IndexManagerTest.php b/Tests/IndexManagerTest.php index 897c3bb..3de78cf 100644 --- a/Tests/IndexManagerTest.php +++ b/Tests/IndexManagerTest.php @@ -1,13 +1,13 @@ diff --git a/Tests/Manager/RepositoryManagerTest.php b/Tests/Manager/RepositoryManagerTest.php index 484bf12..d6be333 100644 --- a/Tests/Manager/RepositoryManagerTest.php +++ b/Tests/Manager/RepositoryManagerTest.php @@ -1,8 +1,8 @@ getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); @@ -24,17 +24,17 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entityName = 'FOQ\ElasticaBundle\Tests\Manager\Entity'; + $entityName = 'FOS\ElasticaBundle\Tests\Manager\Entity'; $manager = new RepositoryManager($readerMock); $manager->addEntity($entityName, $finderMock); $repository = $manager->getRepository($entityName); - $this->assertInstanceOf('FOQ\ElasticaBundle\Repository', $repository); + $this->assertInstanceOf('FOS\ElasticaBundle\Repository', $repository); } public function testThatGetRepositoryReturnsCustomRepository() { - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); @@ -42,12 +42,12 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entityName = 'FOQ\ElasticaBundle\Tests\Manager\Entity'; + $entityName = 'FOS\ElasticaBundle\Tests\Manager\Entity'; $manager = new RepositoryManager($readerMock); - $manager->addEntity($entityName, $finderMock, 'FOQ\ElasticaBundle\Tests\Manager\CustomRepository'); + $manager->addEntity($entityName, $finderMock, 'FOS\ElasticaBundle\Tests\Manager\CustomRepository'); $repository = $manager->getRepository($entityName); - $this->assertInstanceOf('FOQ\ElasticaBundle\Tests\Manager\CustomRepository', $repository); + $this->assertInstanceOf('FOS\ElasticaBundle\Tests\Manager\CustomRepository', $repository); } /** @@ -55,7 +55,7 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase */ public function testThatGetRepositoryThrowsExceptionIfEntityNotConfigured() { - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); @@ -63,7 +63,7 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entityName = 'FOQ\ElasticaBundle\Tests\Manager\Entity'; + $entityName = 'FOS\ElasticaBundle\Tests\Manager\Entity'; $manager = new RepositoryManager($readerMock); $manager->addEntity($entityName, $finderMock); @@ -75,7 +75,7 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase */ public function testThatGetRepositoryThrowsExceptionIfCustomRepositoryNotFound() { - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); @@ -83,10 +83,10 @@ class RepositoryManagerTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entityName = 'FOQ\ElasticaBundle\Tests\Manager\Entity'; + $entityName = 'FOS\ElasticaBundle\Tests\Manager\Entity'; $manager = new RepositoryManager($readerMock); - $manager->addEntity($entityName, $finderMock, 'FOQ\ElasticaBundle\Tests\MissingRepository'); + $manager->addEntity($entityName, $finderMock, 'FOS\ElasticaBundle\Tests\MissingRepository'); $manager->getRepository('Missing Entity'); } diff --git a/Tests/MappingRegistryTest.php b/Tests/MappingRegistryTest.php index 197eb29..cd2af64 100644 --- a/Tests/MappingRegistryTest.php +++ b/Tests/MappingRegistryTest.php @@ -1,8 +1,8 @@ getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate')); + $provider = $this->getMock('FOS\ElasticaBundle\Provider\ProviderInterface', array('populate')); $populator = new PopulatorMock(array()); $populator->addProvider('l3l0Provider', $provider); $this->assertEquals(count($populator->providers), 1); $this->assertArrayHasKey('l3l0Provider', $populator->providers); - $this->assertInstanceOf('FOQ\ElasticaBundle\Provider\ProviderInterface', $populator->providers['l3l0Provider']); + $this->assertInstanceOf('FOS\ElasticaBundle\Provider\ProviderInterface', $populator->providers['l3l0Provider']); } public function testThatPopulateThroughProviders() { - $provider = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate')); + $provider = $this->getMock('FOS\ElasticaBundle\Provider\ProviderInterface', array('populate')); $provider->expects($this->once()) ->method('populate'); - $provider2 = $this->getMock('FOQ\ElasticaBundle\Provider\ProviderInterface', array('populate')); + $provider2 = $this->getMock('FOS\ElasticaBundle\Provider\ProviderInterface', array('populate')); $provider2->expects($this->once()) ->method('populate'); diff --git a/Tests/RepositoryTest.php b/Tests/RepositoryTest.php index 6d51f29..dfcd118 100644 --- a/Tests/RepositoryTest.php +++ b/Tests/RepositoryTest.php @@ -1,8 +1,8 @@ @@ -14,7 +14,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase { $testQuery = 'Test Query'; - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); $finderMock->expects($this->once()) @@ -30,7 +30,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $testQuery = 'Test Query'; $testLimit = 20; - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); $finderMock->expects($this->once()) @@ -45,7 +45,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase { $testQuery = 'Test Query'; - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); $finderMock->expects($this->once()) @@ -61,7 +61,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $testQuery = 'Test Query'; $testLimit = 20; - $finderMock = $this->getMockBuilder('FOQ\ElasticaBundle\Finder\TransformedFinder') + $finderMock = $this->getMockBuilder('FOS\ElasticaBundle\Finder\TransformedFinder') ->disableOriginalConstructor() ->getMock(); $finderMock->expects($this->once()) diff --git a/Tests/ReseterTest.php b/Tests/ReseterTest.php index 598ae08..7f5d39f 100644 --- a/Tests/ReseterTest.php +++ b/Tests/ReseterTest.php @@ -1,9 +1,9 @@ getMock('FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface'); + $transformer1 = $this->getMock('FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface'); $transformer1->expects($this->any()) ->method('getObjectClass') - ->will($this->returnValue('FOQ\ElasticaBundle\Tests\Transformer\POPO')); + ->will($this->returnValue('FOS\ElasticaBundle\Tests\Transformer\POPO')); $transformer1->expects($this->any()) ->method('getIdentifierField') ->will($this->returnValue('id')); - $transformer2 = $this->getMock('FOQ\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface'); + $transformer2 = $this->getMock('FOS\ElasticaBundle\Transformer\ElasticaToModelTransformerInterface'); $transformer2->expects($this->any()) ->method('getObjectClass') - ->will($this->returnValue('FOQ\ElasticaBundle\Tests\Transformer\POPO2')); + ->will($this->returnValue('FOS\ElasticaBundle\Tests\Transformer\POPO2')); $transformer2->expects($this->any()) ->method('getIdentifierField') @@ -44,8 +44,8 @@ class ElasticaToModelTransformerCollectionTest extends \PHPUnit_Framework_TestCa $objectClasses = $this->collection->getObjectClass(); $this->assertEquals(array( - 'type1' => 'FOQ\ElasticaBundle\Tests\Transformer\POPO', - 'type2' => 'FOQ\ElasticaBundle\Tests\Transformer\POPO2' + 'type1' => 'FOS\ElasticaBundle\Tests\Transformer\POPO', + 'type2' => 'FOS\ElasticaBundle\Tests\Transformer\POPO2' ), $objectClasses); } diff --git a/Tests/Transformer/ModelToElasticaAutoTransformerTest.php b/Tests/Transformer/ModelToElasticaAutoTransformerTest.php index b001d7a..0044635 100644 --- a/Tests/Transformer/ModelToElasticaAutoTransformerTest.php +++ b/Tests/Transformer/ModelToElasticaAutoTransformerTest.php @@ -1,8 +1,8 @@ - + ./Tests