Skip to content
This repository was archived by the owner on May 9, 2019. It is now read-only.

Commit c6c6c27

Browse files
authored
Publicly expose index replicas (#423)
1 parent 9c00ed2 commit c6c6c27

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

includes/indices/class-algolia-index-replica.php

+14
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,18 @@ public function get_replica_index_name( Algolia_Index $index ) {
4444
public function get_ranking() {
4545
return array( $this->order . '(' . $this->attribute_name . ')', 'typo', 'geo', 'words', 'filters', 'proximity', 'attribute', 'exact', 'custom' );
4646
}
47+
48+
/**
49+
* @return string
50+
*/
51+
public function get_attribute_name() {
52+
return $this->attribute_name;
53+
}
54+
55+
/**
56+
* @return string
57+
*/
58+
public function get_order() {
59+
return $this->order;
60+
}
4761
}

includes/indices/class-algolia-index.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,27 @@ final public function handle_task( Algolia_Task $task ) {
462462
* @return array
463463
*/
464464
public function to_array() {
465+
$replicas = $this->get_replicas();
466+
467+
$items = array();
468+
foreach ( $replicas as $replica ) {
469+
$items[] = array(
470+
'name' => $replica->get_replica_index_name( $this ),
471+
);
472+
}
473+
465474
return array(
466475
'name' => $this->get_name(),
467476
'id' => $this->get_id(),
468-
'enabled' => $this->enabled,
477+
'enabled' => $this->enabled,
478+
'replicas' => $items
469479
);
470480
}
471481

472482
/**
473483
* @return array
474484
*/
475-
protected function get_replicas() {
485+
public function get_replicas() {
476486
$replicas = (array) apply_filters( 'algolia_index_replicas', array(), $this );
477487
$replicas = (array) apply_filters( 'algolia_' . $this->get_id() . '_index_replicas', $replicas, $this );
478488

0 commit comments

Comments
 (0)