reverted: --- b/src/Form/IndexStatusForm.php +++ a/src/Form/IndexStatusForm.php @@ -65,7 +65,6 @@ $form['#attached']['library'][] = 'search_api/drupal.search_api.admin_css'; if ($index->hasValidTracker()) { - $tracker = $index->getTrackerInstance(); if (!$this->getIndexTaskManager()->isTrackingComplete($index)) { $form['tracking'] = array( '#type' => 'details', @@ -83,29 +82,6 @@ ); } - - // Add the "Index details per datasource". - $datasource_details = array(); - $form['datasource_details'] = array( - '#type' => 'details', - '#title' => $this->t('Index details per datasource'), - ); - - $total_per_datasource = $tracker->getTotalItemsCountPerDatasource(); - $indexed_per_datasource = $tracker->getIndexedItemsCountPerDatasource(); - - foreach ($total_per_datasource as $did => $count) { - $datasource_details[] = $this->t('@datasource: @indexed/@total indexed', array( - '@datasource' => $index->getDatasource($did)->label(), - '@indexed' => isset($indexed_per_datasource[$did]) ? $indexed_per_datasource[$did] : 0, - '@total' => $count, - )); - } - $form['datasource_details']['indexed_per_datasource'] = array( - '#theme' => 'item_list', - '#items' => $datasource_details, - ); - // Add the "Index now" form. $form['index'] = array( '#type' => 'details', @@ -115,7 +91,7 @@ 'class' => array('container-inline'), ), ); + $has_remaining_items = ($index->getTrackerInstance()->getRemainingItemsCount() > 0); - $has_remaining_items = ($tracker->getRemainingItemsCount() > 0); $all_value = $this->t('all', array(), array('context' => 'items to index')); $limit = array( '#type' => 'textfield', reverted: --- b/src/Tracker/TrackerInterface.php +++ a/src/Tracker/TrackerInterface.php @@ -121,29 +121,4 @@ */ public function getRemainingItemsCount($datasource_id = NULL); - /** - * Retrieves the total number of items that are being tracked for this index - * per datasource. - * - * @param string|null $datasource_id - * (optional) The datasource to filter the total number of indexed items by. - * - * @return array - * The total number of items that are tracked for this index, or for the - * given datasource on this index. - */ - public function getTotalItemsCountPerDatasource($datasource_id = NULL); - - /** - * Retrieves the number of indexed items for this index per datasource. - * - * @param string|null $datasource_id - * (optional) The datasource to filter the total number of indexed items by. - * - * @return array - * The number of items that have been indexed in their latest state for this - * index, or for the given datasource on this index. - */ - public function getIndexedItemsCountPerDatasource($datasource_id = NULL); - } only in patch2: unchanged: --- a/search_api.theme.inc +++ b/search_api.theme.inc @@ -7,10 +7,12 @@ use Drupal\Component\Utility\Html; use Drupal\Core\Render\Element; +use Drupal\Core\Render\Markup; use Drupal\Core\Url; use Drupal\search_api\Query\QueryInterface; use Drupal\search_api\SearchApiException; use Drupal\search_api\Utility\Utility; +use Drupal\search_api\Tracker\TrackerPerDatasourceInterface; /** * Returns HTML for a fields form table. @@ -406,6 +408,32 @@ function theme_search_api_index(array $variables) { $rows[] = Utility::deepCopy($row); $classes = []; + // Add the index details per datasource. + if ($tracker && ($tracker instanceof TrackerPerDatasourceInterface)) { + $indexed_per_datasource = $tracker->getTotalItemsCountPerDatasource(); + $total_per_datasource = $tracker->getIndexedItemsCountPerDatasource(); + + // Add it if our index is multiple. + if ($total_per_datasource && $total_per_datasource >= 2) { + $datasource_details = []; + + foreach ($total_per_datasource as $did => $count) { + $datasource_details[] = t('@datasource: @indexed/@total indexed', [ + '@datasource' => $index->getDatasource($did)->label(), + '@indexed' => isset($indexed_per_datasource[$did]) ? $indexed_per_datasource[$did] : 0, + '@total' => $count, + ]); + } + + if ($datasource_details) { + $label = t('Index details per datasource'); + $message = '' . implode(PHP_EOL, $datasource_details) . ''; + $info = Markup::create(nl2br($message)); + $rows[] = Utility::deepCopy($row); + } + } + } + // Check if a server is available. $classes[] = 'search-api-index-summary--server'; if ($server) { only in patch2: unchanged: --- a/src/Tracker/TrackerPluginBase.php +++ b/src/Tracker/TrackerPluginBase.php @@ -29,9 +29,10 @@ use Drupal\search_api\Plugin\IndexPluginBase; * @see \Drupal\search_api\Annotation\SearchApiTracker * @see \Drupal\search_api\Tracker\TrackerPluginManager * @see \Drupal\search_api\Tracker\TrackerInterface + * @see \Drupal\search_api\Tracker\TrackerPerDatasourceInterface * @see plugin_api */ -abstract class TrackerPluginBase extends IndexPluginBase implements TrackerInterface { +abstract class TrackerPluginBase extends IndexPluginBase implements TrackerInterface, TrackerPerDatasourceInterface { // @todo Move some of the methods from // \Drupal\search_api\Plugin\search_api\tracker\Basic to here?