Fix previous commits

This commit is contained in:
Tim Nagel 2014-06-16 22:43:16 +10:00
parent 7682d5a80a
commit 813a4a5d26
5 changed files with 31 additions and 18 deletions

View file

@ -2,11 +2,11 @@
namespace FOS\ElasticaBundle;
use FOS\ElasticaBundle\Elastica\LoggingClient;
use FOS\ElasticaBundle\Elastica\Client as BaseClient;
/**
* @deprecated Use \FOS\ElasticaBundle\Elastica\LoggingClient
*/
class Client extends LoggingClient
class Client extends BaseClient
{
}

View file

@ -183,11 +183,11 @@ class Configuration implements ConfigurationInterface
->beforeNormalization()
->ifTrue(function($v) { return isset($v['mappings']); })
->then(function($v) {
$v['properties'] = $v['mappings'];
unset($v['mappings']);
$v['properties'] = $v['mappings'];
unset($v['mappings']);
return $v;
})
return $v;
})
->end()
->children()
->scalarNode('index_analyzer')->end()

View file

@ -72,6 +72,7 @@ class FOSElasticaExtension extends Extension
$container->setAlias('fos_elastica.index', sprintf('fos_elastica.index.%s', $config['default_index']));
$this->loadIndexManager($container);
$this->loadResetter($container);
$this->createDefaultManagerAlias($config['default_manager'], $container);
}
@ -132,7 +133,7 @@ class FOSElasticaExtension extends Extension
$indexDef = new DefinitionDecorator('fos_elastica.index_prototype');
$indexDef->replaceArgument(0, $indexName);
if ($index['client']) {
if (isset($index['client'])) {
$client = $this->getClient($index['client']);
$indexDef->setFactoryService($client);
}
@ -146,7 +147,7 @@ class FOSElasticaExtension extends Extension
'settings' => $index['settings']
),
'elasticsearch_name' => $indexName,
'index' => $reference,
'reference' => $reference,
'name' => $name,
'type_prototype' => isset($index['type_prototype']) ? $index['type_prototype'] : array(),
'use_alias' => $index['use_alias'],
@ -220,7 +221,9 @@ class FOSElasticaExtension extends Extension
'_timestamp',
'_ttl',
) as $field) {
$this->indexConfigs[$indexName]['config']['properties'][$name][$field] = $type[$field];
if (array_key_exists($field, $type)) {
$this->indexConfigs[$indexName]['config']['properties'][$name][$field] = $type[$field];
}
}
if (!empty($type['dynamic_templates'])) {
@ -390,7 +393,7 @@ class FOSElasticaExtension extends Extension
if ($this->serializerConfig) {
$abstractId = 'fos_elastica.object_serializer_persister';
$callbackId = sprintf('%s.%s.serializer.callback', $this->indexConfigs[$indexName]['index'], $typeName);
$callbackId = sprintf('%s.%s.serializer.callback', $this->indexConfigs[$indexName]['reference'], $typeName);
$arguments[] = array(new Reference($callbackId), 'serialize');
} else {
$abstractId = 'fos_elastica.object_persister';
@ -622,4 +625,15 @@ class FOSElasticaExtension extends Extension
return $this->clients[$clientName]['reference'];
}
/**
* Loads the resetter
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
private function loadResetter(ContainerBuilder $container)
{
$resetterDef = $container->getDefinition('fos_elastica.resetter');
$resetterDef->replaceArgument(0, $this->indexConfigs);
}
}

View file

@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="fos_elastica.client.class">FOS\ElasticaBundle\Elastica\LoggingClient</parameter>
<parameter key="fos_elastica.client.class">FOS\ElasticaBundle\Elastica\Client</parameter>
<parameter key="fos_elastica.logger.class">FOS\ElasticaBundle\Logger\ElasticaLogger</parameter>
<parameter key="fos_elastica.data_collector.class">FOS\ElasticaBundle\DataCollector\ElasticaDataCollector</parameter>
<parameter key="fos_elastica.property_accessor.class">Symfony\Component\PropertyAccess\PropertyAccessor</parameter>
@ -15,7 +15,11 @@
<service id="fos_elastica.client_prototype" class="%fos_elastica.client.class%" abstract="true">
<argument type="collection" /> <!-- configuration -->
<argument /> <!-- callback -->
<argument type="service" id="fos_elastica.transformer.combined" />
</service>
<service id="fos_elastica.data_collector" class="%fos_elastica.data_collector.class%">
<tag name="data_collector" template="FOSElasticaBundle:Collector:elastica" id="elastica" />
<argument type="service" id="fos_elastica.logger" />
</service>
<service id="fos_elastica.logger" class="%fos_elastica.logger.class%">
@ -24,11 +28,6 @@
<tag name="monolog.logger" channel="elastica" />
</service>
<service id="fos_elastica.data_collector" class="%fos_elastica.data_collector.class%" public="true">
<tag name="data_collector" template="FOSElasticaBundle:Collector:elastica" id="elastica" />
<argument type="service" id="fos_elastica.logger" />
</service>
<service id="fos_elastica.property_accessor" class="%fos_elastica.property_accessor.class%" />
</services>
</container>

View file

@ -28,7 +28,7 @@ class LoggingClientTest extends \PHPUnit_Framework_TestCase
$this->isType('array')
);
$client = $this->getMockBuilder('FOS\ElasticaBundle\Elastica\LoggingClient')
$client = $this->getMockBuilder('FOS\ElasticaBundle\Elastica\Client')
->setMethods(array('getConnection'))
->getMock();