Add reseter service and command
This commit is contained in:
parent
02dd4d85cc
commit
15f24fcb59
3 changed files with 39 additions and 6 deletions
29
Reseter.php
Normal file
29
Reseter.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace FOQ\ElasticaBundle;
|
||||
|
||||
/**
|
||||
* Deletes and recreates indexes
|
||||
**/
|
||||
class Reseter
|
||||
{
|
||||
protected $indexManager;
|
||||
|
||||
public function __construct(IndexManager $indexManager)
|
||||
{
|
||||
$this->indexManager = $indexManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets all indexes
|
||||
*
|
||||
* @return null
|
||||
**/
|
||||
public function reset()
|
||||
{
|
||||
foreach ($this->indexManager->getAllIndexes() as $index) {
|
||||
$index->delete();
|
||||
$index->create();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue