mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Rename GlobalElasticOptions ElasticsearchOptions
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
namespace Alchemy\Phrasea\Controller\Admin;
|
namespace Alchemy\Phrasea\Controller\Admin;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\Controller;
|
use Alchemy\Phrasea\Controller\Controller;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticSearchSettingFormType;
|
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchSettingsFormType;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\GlobalElasticOptions;
|
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@@ -25,7 +25,7 @@ class SearchEngineController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function formConfigurationPanelAction(Request $request)
|
public function formConfigurationPanelAction(Request $request)
|
||||||
{
|
{
|
||||||
$options = $this->getElasticSearchOptions();
|
$options = $this->getElasticsearchOptions();
|
||||||
$form = $this->getConfigurationForm($options);
|
$form = $this->getConfigurationForm($options);
|
||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
@@ -42,29 +42,29 @@ class SearchEngineController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return GlobalElasticOptions
|
* @return ElasticsearchOptions
|
||||||
*/
|
*/
|
||||||
private function getElasticSearchOptions()
|
private function getElasticsearchOptions()
|
||||||
{
|
{
|
||||||
return $this->app['elasticsearch.options'];
|
return $this->app['elasticsearch.options'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GlobalElasticOptions $configuration
|
* @param ElasticsearchOptions $configuration
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function saveElasticSearchOptions(GlobalElasticOptions $configuration)
|
private function saveElasticSearchOptions(ElasticsearchOptions $configuration)
|
||||||
{
|
{
|
||||||
$this->getConf()->set(['main', 'search-engine', 'options'], $configuration->toArray());
|
$this->getConf()->set(['main', 'search-engine', 'options'], $configuration->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GlobalElasticOptions $options
|
* @param ElasticsearchOptions $options
|
||||||
* @return FormInterface
|
* @return FormInterface
|
||||||
*/
|
*/
|
||||||
private function getConfigurationForm(GlobalElasticOptions $options)
|
private function getConfigurationForm(ElasticsearchOptions $options)
|
||||||
{
|
{
|
||||||
return $this->app->form(new ElasticSearchSettingFormType(), $options, [
|
return $this->app->form(new ElasticsearchSettingsFormType(), $options, [
|
||||||
'action' => $this->app->url('admin_searchengine_form'),
|
'action' => $this->app->url('admin_searchengine_form'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
namespace Alchemy\Phrasea\Core\Provider;
|
namespace Alchemy\Phrasea\Core\Provider;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Controller\LazyLocator;
|
use Alchemy\Phrasea\Controller\LazyLocator;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\GlobalElasticOptions;
|
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineLogger;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineLogger;
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||||
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||||
@@ -54,7 +54,7 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
|
|||||||
if ($type !== SearchEngineInterface::TYPE_ELASTICSEARCH) {
|
if ($type !== SearchEngineInterface::TYPE_ELASTICSEARCH) {
|
||||||
throw new InvalidArgumentException(sprintf('Invalid search engine type "%s".', $type));
|
throw new InvalidArgumentException(sprintf('Invalid search engine type "%s".', $type));
|
||||||
}
|
}
|
||||||
/** @var GlobalElasticOptions $options */
|
/** @var ElasticsearchOptions $options */
|
||||||
$options = $app['elasticsearch.options'];
|
$options = $app['elasticsearch.options'];
|
||||||
|
|
||||||
return new ElasticSearchEngine(
|
return new ElasticSearchEngine(
|
||||||
@@ -136,7 +136,7 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
|
|||||||
/* Low-level elasticsearch services */
|
/* Low-level elasticsearch services */
|
||||||
|
|
||||||
$app['elasticsearch.client'] = $app->share(function($app) {
|
$app['elasticsearch.client'] = $app->share(function($app) {
|
||||||
/** @var GlobalElasticOptions $options */
|
/** @var ElasticsearchOptions $options */
|
||||||
$options = $app['elasticsearch.options'];
|
$options = $app['elasticsearch.options'];
|
||||||
$clientParams = ['hosts' => [sprintf('%s:%s', $options->getHost(), $options->getPort())]];
|
$clientParams = ['hosts' => [sprintf('%s:%s', $options->getHost(), $options->getPort())]];
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$app['elasticsearch.options'] = $app->share(function($app) {
|
$app['elasticsearch.options'] = $app->share(function($app) {
|
||||||
$options = GlobalElasticOptions::fromArray($app['conf']->get(['main', 'search-engine', 'options'], []));
|
$options = ElasticsearchOptions::fromArray($app['conf']->get(['main', 'search-engine', 'options'], []));
|
||||||
|
|
||||||
if (empty($options->getIndexName())) {
|
if (empty($options->getIndexName())) {
|
||||||
$options->setIndexName(strtolower(sprintf('phraseanet_%s', str_replace(
|
$options->setIndexName(strtolower(sprintf('phraseanet_%s', str_replace(
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace Alchemy\Phrasea\SearchEngine\Elastic;
|
namespace Alchemy\Phrasea\SearchEngine\Elastic;
|
||||||
|
|
||||||
class GlobalElasticOptions
|
class ElasticsearchOptions
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $host;
|
private $host;
|
@@ -14,7 +14,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
use Symfony\Component\Validator\Constraints\Range;
|
use Symfony\Component\Validator\Constraints\Range;
|
||||||
|
|
||||||
class ElasticSearchSettingFormType extends AbstractType
|
class ElasticsearchSettingsFormType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
@@ -48,6 +48,6 @@ class ElasticSearchSettingFormType extends AbstractType
|
|||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'elastic_settings';
|
return 'elasticsearch_settings';
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -32,7 +32,7 @@ class Indexer
|
|||||||
|
|
||||||
/** @var \Elasticsearch\Client */
|
/** @var \Elasticsearch\Client */
|
||||||
private $client;
|
private $client;
|
||||||
/** @var GlobalElasticOptions */
|
/** @var ElasticsearchOptions */
|
||||||
private $options;
|
private $options;
|
||||||
private $appbox;
|
private $appbox;
|
||||||
/** @var LoggerInterface|null */
|
/** @var LoggerInterface|null */
|
||||||
@@ -49,7 +49,7 @@ class Indexer
|
|||||||
const DEFAULT_REFRESH_INTERVAL = '1s';
|
const DEFAULT_REFRESH_INTERVAL = '1s';
|
||||||
const REFRESH_INTERVAL_KEY = 'index.refresh_interval';
|
const REFRESH_INTERVAL_KEY = 'index.refresh_interval';
|
||||||
|
|
||||||
public function __construct(Client $client, GlobalElasticOptions $options, TermIndexer $termIndexer, RecordIndexer $recordIndexer, appbox $appbox, LoggerInterface $logger = null)
|
public function __construct(Client $client, ElasticsearchOptions $options, TermIndexer $termIndexer, RecordIndexer $recordIndexer, appbox $appbox, LoggerInterface $logger = null)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
@@ -24,12 +24,12 @@ class Thesaurus
|
|||||||
{
|
{
|
||||||
/** @var Client */
|
/** @var Client */
|
||||||
private $client;
|
private $client;
|
||||||
/** @var GlobalElasticOptions */
|
/** @var ElasticsearchOptions */
|
||||||
private $options;
|
private $options;
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
public function __construct(Client $client, GlobalElasticOptions $options, LoggerInterface $logger)
|
public function __construct(Client $client, ElasticsearchOptions $options, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
Reference in New Issue
Block a user