class ClusterManager in Elasticsearch Connector 8.5
Same name and namespace in other branches
- 8.7 src/ClusterManager.php \Drupal\elasticsearch_connector\ClusterManager
- 8.6 src/ClusterManager.php \Drupal\elasticsearch_connector\ClusterManager
ClusterManager service.
Hierarchy
- class \Drupal\elasticsearch_connector\ClusterManager
Expanded class hierarchy of ClusterManager
5 files declare their use of ClusterManager
- ClusterDeleteForm.php in src/
Form/ ClusterDeleteForm.php - ClusterForm.php in src/
Form/ ClusterForm.php - ClusterManagerTest.php in tests/
src/ Unit/ ClusterManagerTest.php - IndexForm.php in src/
Form/ IndexForm.php - SearchApiElasticsearchBackend.php in src/
Plugin/ search_api/ backend/ SearchApiElasticsearchBackend.php
1 string reference to 'ClusterManager'
1 service uses ClusterManager
File
- src/
ClusterManager.php, line 11
Namespace
Drupal\elasticsearch_connectorView source
class ClusterManager {
/**
* The state storage service.
*
* @var \Drupal\Node\NodeStorageInterface
*/
protected $state;
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* ClusterManager constructor.
*
* @param \Drupal\Core\State\StateInterface $state
* The state storage service.
*/
public function __construct(StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {
$this->state = $state;
$this->entityTypeManager = $entity_type_manager;
}
/**
* Get the default (cluster) used by Elasticsearch.
*
* @return string
* The cluster identifier.
*/
public function getDefaultCluster() {
return $this->state
->get('elasticsearch_connector_get_default_connector', '');
}
/**
* Set the default (cluster) used by Elasticsearch.
*
* @param string $cluster_id
* The new cluster identifier.
*/
public function setDefaultCluster($cluster_id) {
$this->state
->set('elasticsearch_connector_get_default_connector', $cluster_id);
}
/**
* Load all clusters.
*
* @param bool $include_inactive
*
* @return \Drupal\elasticsearch_connector\Entity\Cluster[]
*/
public function loadAllClusters($include_inactive = TRUE) {
$clusters = $this->entityTypeManager
->getStorage('elasticsearch_cluster')
->loadMultiple();
foreach ($clusters as $cluster) {
if (!$include_inactive && !$cluster->status) {
unset($clusters[$cluster->cluster_id]);
}
}
return $clusters;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClusterManager:: |
protected | property | The entity type manager service. | |
ClusterManager:: |
protected | property | The state storage service. | |
ClusterManager:: |
public | function | Get the default (cluster) used by Elasticsearch. | |
ClusterManager:: |
public | function | Load all clusters. | |
ClusterManager:: |
public | function | Set the default (cluster) used by Elasticsearch. | |
ClusterManager:: |
public | function | ClusterManager constructor. |