You are here

public function NewResultsCheck::getTypesWithNotification in Search API Saved Searches 8

Retrieves the saved search types that have any notification plugins set.

Return value

string[]|null Either an array containing the IDs of all saved search types that are both enabled and have at least one notification plugin set (which might be an empty array). Or NULL if all existing types match these criteria.

1 call to NewResultsCheck::getTypesWithNotification()
NewResultsCheck::getSearchesToCheck in src/Service/NewResultsCheck.php
Determines the saved searches that should be checked for new results.

File

src/Service/NewResultsCheck.php, line 188

Class

NewResultsCheck
Provides a service for checking saved searches for new results.

Namespace

Drupal\search_api_saved_searches\Service

Code

public function getTypesWithNotification() {

  /** @var \Drupal\search_api_saved_searches\SavedSearchTypeInterface[] $types */
  $types = $this
    ->getSearchTypeStorage()
    ->loadMultiple();
  $all = TRUE;
  foreach ($types as $id => $type) {
    if (!$type
      ->status() || !$type
      ->getNotificationPluginIds()) {
      unset($types[$id]);
      $all = FALSE;
    }
  }
  return $all ? NULL : array_keys($types);
}