1111 * source code.
1212 */
1313
14+ use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Service \IndexNameStrategyInterface ;
1415use Neos \Flow \Annotations as Flow ;
1516use Neos \Flow \Configuration \ConfigurationManager ;
1617
2728class ElasticSearchClient extends \Flowpack \ElasticSearch \Domain \Model \Client
2829{
2930 /**
30- * The index name to be used for querying (by default "neoscr")
31- *
32- * @var string
33- */
34- protected $ indexName ;
35-
36- /**
31+ * @var IndexNameStrategyInterface
3732 * @Flow\Inject
38- * @var ConfigurationManager
39- */
40- protected $ configurationManager ;
41-
42- /**
43- * Called by the Flow object framework after creating the object and resolving all dependencies.
44- *
45- * @param integer $cause Creation cause
4633 */
47- public function initializeObject ($ cause )
48- {
49- if ($ cause === \Neos \Flow \ObjectManagement \ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED ) {
50- $ settings = $ this ->configurationManager ->getConfiguration (ConfigurationManager::CONFIGURATION_TYPE_SETTINGS , 'Neos.ContentRepository.Search ' );
51- $ this ->indexName = $ settings ['elasticSearch ' ]['indexName ' ];
52- }
53- }
34+ protected $ indexNameStrategy ;
5435
5536 /**
5637 * Get the index name to be used
@@ -59,7 +40,11 @@ public function initializeObject($cause)
5940 */
6041 public function getIndexName ()
6142 {
62- return $ this ->indexName ;
43+ $ name = trim ($ this ->indexNameStrategy ->get ());
44+ if ($ name === '' ) {
45+ throw new Exception ('Index name can not be null ' );
46+ }
47+ return $ name ;
6348 }
6449
6550 /**
@@ -70,6 +55,6 @@ public function getIndexName()
7055 */
7156 public function getIndex ()
7257 {
73- return $ this ->findIndex ($ this ->indexName );
58+ return $ this ->findIndex ($ this ->getIndexName () );
7459 }
7560}
0 commit comments