I'm using the elasticsearch connector module for Drupal 8 to manage indexes. https://www.drupal.org/project/elasticsearch_connector
One thing I need to happen on index creation time is to add some analyzers and filters to the elasticsearch index mapping.
I've tracked down the place that's happening here in the create() method for one of their classes:
modules\contrib\elasticsearch_connector\src\ElasticSearch\Parameters\Factory\IndexFactory.php
I have a custom module that I'm trying to extend that method and add to it but can't seem to get it to fire. I have the module enabled properly as it shows up on the extend page. So far my folder structure for my custom module looks like this:
modules\custom\elasticsearch_analyzer\src\elasticsearch_analyzer.php
<?php
namespace Drupal\elasticsearch_analyzer;
use Drupal\search_api\IndexInterface;
use Drupal\elasticsearch_connector\ElasticSearch\Parameters\Factory\IndexFactory;
class elasticsearch_analyzer extends IndexFactory {
/**
* {@inheritdoc}
*/
public static function create(IndexInterface $index) {
die('does this work?');
return [
'index' => IndexFactory::getIndexName($index),
'body' => [
'settings' => [
'number_of_shards' => $index->getOption('number_of_shards', 5),
'number_of_replicas' => $index->getOption('number_of_replicas', 1),
],
],
];
}
}
I've tried a bunch of different combinations surrounding the PSR-4 standard, but can't seem to get it to run. Is this how we'd normally go about extending things in Drupal 8? Should I just be putting this class in the .module file at the root of my module? Should I be registering this as a service?
Based on the tutorials I've read, I haven't been able to see any examples of extending contributed modules or core outside of creating block plugins or simple route pages. I thought now that we're out of the hook world I should be able to examine code within an existing class and override it using OOP inheritance. Or is that not the case?