diff --git a/src/Backend/BackendInterface.php b/src/Backend/BackendInterface.php index 55038c3..75d18d1 100644 --- a/src/Backend/BackendInterface.php +++ b/src/Backend/BackendInterface.php @@ -81,4 +81,26 @@ interface BackendInterface extends ConfigurablePluginInterface, BackendSpecificI */ public function preDelete(); + /** + * Extra information that the backend plugin can provide about it's status. + * + * An example of provided information is the status of the underlying server, + * through a ping to the server. This would absolutely make sense for SOLR and + * elasticsearch but would not make sense for a database-backend when that is + * the same database as the one Drupal is running from. + * + * The data should an array with the keys: + * - status: A string that can be used to color the row, default is info. + * - label: The label of the of the message, shown in the left column. + * This should be translatable. + * - description: The description of the message, shown in the right column. + * This should be translatable. + * + * Because multiple of these can be returned, the backend should return an + * array of arrays. + * + * @return array[] + */ + public function getExtraInformation(); + } diff --git a/src/Backend/BackendPluginBase.php b/src/Backend/BackendPluginBase.php index ecb1662..b209804 100644 --- a/src/Backend/BackendPluginBase.php +++ b/src/Backend/BackendPluginBase.php @@ -154,6 +154,13 @@ abstract class BackendPluginBase extends ConfigurablePluginBase implements Backe public function removeIndex($index) {} /** + * {@inheritdoc} + */ + public function getExtraInformation() { + return array(); + } + + /** * Implements the magic __sleep() method. * * Prevents the server entity from being serialized. diff --git a/tests/search_api_test_backend/src/Plugin/search_api/backend/TestBackend.php b/tests/search_api_test_backend/src/Plugin/search_api/backend/TestBackend.php index cd044f3..ead1b43 100644 --- a/tests/search_api_test_backend/src/Plugin/search_api/backend/TestBackend.php +++ b/tests/search_api_test_backend/src/Plugin/search_api/backend/TestBackend.php @@ -66,6 +66,24 @@ class TestBackend extends BackendPluginBase { /** * {@inheritdoc} */ + public function getExtraInformation() { + return array( + array( + 'status' => 'info', + 'label' => 'information', + 'description' => $this->t('Just some random information') + ), + array( + 'status' => 'warning', + 'label' => $this->t('Server status'), + 'description' => $this->t('The server responded slowly. Speed it up.') + ) + ); + } + + /** + * {@inheritdoc} + */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $form['test'] = array( '#type' => 'textfield',