Remove mapping and setting registries, use the reseter to configure the indexes

This commit is contained in:
ornicar 2011-09-12 18:28:59 +02:00
commit 451a5b4fc2
7 changed files with 40 additions and 160 deletions

View file

@ -9,11 +9,16 @@ use Elastica_Exception_Response;
**/
class Reseter
{
protected $indexManager;
/**
* Index settings and mappings
*
* @var array
*/
protected $indexConfigs;
public function __construct(IndexManager $indexManager)
public function __construct(array $indexConfigs)
{
$this->indexManager = $indexManager;
$this->indexConfigs = $indexConfigs;
}
/**
@ -23,13 +28,8 @@ class Reseter
**/
public function reset()
{
foreach ($this->indexManager->getAllIndexes() as $index) {
try {
$index->delete();
} catch (Elastica_Exception_Response $e) {
// The index does not exist
}
$index->create();
foreach ($this->indexConfigs as $indexConfig) {
$indexConfig['index']->create($indexConfig['config'], true);
}
}
}