コード例 #1
0
 /**
  * set to final because this is an important step which may not be overridden.
  */
 public final function tearDown()
 {
     parent::tearDown();
     if ($this->removeIndexOnTearDown === TRUE) {
         $this->testingIndex->delete();
     }
 }
コード例 #2
0
 /**
  * Delete an index in ElasticSearch
  *
  * @param string $indexName The name of the index to be removed
  * @param string $clientName The client name to use
  */
 public function deleteCommand($indexName, $clientName = null)
 {
     if (!in_array($indexName, $this->indexInformer->getAllIndexNames())) {
         $this->outputFormatted("The index <b>%s</b> is not configured in the current application", array($indexName));
         $this->quit(1);
     }
     $client = $this->clientFactory->create($clientName);
     try {
         $index = new Index($indexName, $client);
         if (!$index->exists()) {
             $this->outputFormatted("The index <b>%s</b> does not exists", array($indexName));
             $this->quit(1);
         }
         $index->delete();
         $this->outputFormatted("Index <b>%s</b> deleted with success", array($indexName));
     } catch (Exception $exception) {
         $this->outputFormatted("Unable to delete an index named: <b>%s</b>", array($indexName));
         $this->quit(1);
     }
 }