public function NotificationPluginManager::createPlugins in Search API Saved Searches 8
Creates multiple notification plugins for the given saved search type.
Parameters
\Drupal\search_api_saved_searches\SavedSearchTypeInterface $type: The saved search type.
string[]|null $plugin_ids: (optional) The IDs of the plugins to create, or NULL to create instances for all known notification plugins.
array $configurations: (optional) The configurations to set for the plugins, keyed by plugin ID. Missing configurations are either taken from the saved search type's stored settings, if they are present there, or default to an empty array.
Return value
\Drupal\search_api_saved_searches\Notification\NotificationPluginInterface[] The created notification plugins.
Throws
\Drupal\search_api_saved_searches\SavedSearchesException Thrown if an unknown plugin ID is given.
Overrides NotificationPluginManagerInterface::createPlugins
File
- src/
Notification/ NotificationPluginManager.php, line 56
Class
- NotificationPluginManager
- Manages notification plugins.
Namespace
Drupal\search_api_saved_searches\NotificationCode
public function createPlugins(SavedSearchTypeInterface $type, array $plugin_ids = NULL, array $configurations = []) {
if ($plugin_ids === NULL) {
$plugin_ids = array_keys($this
->getDefinitions());
}
$plugins = [];
$type_settings = $type
->get('notification_settings');
foreach ($plugin_ids as $plugin_id) {
$configuration = [];
if (isset($configurations[$plugin_id])) {
$configuration = $configurations[$plugin_id];
}
elseif (isset($type_settings[$plugin_id])) {
$configuration = $type_settings[$plugin_id];
}
$plugins[$plugin_id] = $this
->createPlugin($type, $plugin_id, $configuration);
}
return $plugins;
}