2014-04-21 01:21:50 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FOS\ElasticaBundle\Elastica;
|
|
|
|
|
|
|
|
use Elastica\Index as BaseIndex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overridden Elastica Index class that provides dynamic index name changes.
|
|
|
|
*
|
|
|
|
* @author Konstantin Tjuterev <kostik.lv@gmail.com>
|
|
|
|
*/
|
|
|
|
class Index extends BaseIndex
|
|
|
|
{
|
2014-06-17 14:42:15 +02:00
|
|
|
private $originalName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the original name of the index if the index has been renamed for reindexing
|
|
|
|
* or realiasing purposes.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOriginalName()
|
|
|
|
{
|
|
|
|
return $this->originalName ?: $this->_name;
|
|
|
|
}
|
|
|
|
|
2014-04-21 01:21:50 +02:00
|
|
|
/**
|
|
|
|
* Reassign index name
|
|
|
|
*
|
|
|
|
* While it's technically a regular setter for name property, it's specifically named overrideName, but not setName
|
|
|
|
* since it's used for a very specific case and normally should not be used
|
|
|
|
*
|
|
|
|
* @param string $name Index name
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function overrideName($name)
|
|
|
|
{
|
2014-06-17 14:42:15 +02:00
|
|
|
$this->originalName = $this->_name;
|
2014-04-21 01:21:50 +02:00
|
|
|
$this->_name = $name;
|
|
|
|
}
|
|
|
|
}
|