You are here

public function SchedulerManager::getPlugins in Scheduler 2.x

Gets instances of applicable Scheduler plugins for the enabled modules.

Parameters

string $provider: Optional. Filter the plugins to return only those that are provided by the named $provider module.

Return value

array Array of plugin objects, keyed by the entity type the plugin supports.

8 calls to SchedulerManager::getPlugins()
SchedulerManager::getDevelGenerateFormIds in src/SchedulerManager.php
Gets the supported Devel Generate form IDs.
SchedulerManager::getEntityFormIds in src/SchedulerManager.php
Gets list of entity add/edit form IDs.
SchedulerManager::getEntityTypeFormIds in src/SchedulerManager.php
Gets list of entity type add/edit form IDs.
SchedulerManager::getPlugin in src/SchedulerManager.php
Get a plugin for a specific entity type.
SchedulerManager::getPluginEntityTypes in src/SchedulerManager.php
Get the supported entity types applicable to the currently enabled modules.

... See full list

File

src/SchedulerManager.php, line 889

Class

SchedulerManager
Defines a scheduler manager.

Namespace

Drupal\scheduler

Code

public function getPlugins(string $provider = NULL) {
  $cache = \Drupal::cache()
    ->get('scheduler.plugins');
  if (!empty($cache) && !empty($cache->data) && empty($provider)) {
    return $cache->data;
  }
  $definitions = $this
    ->getPluginDefinitions();
  $plugins = [];
  foreach ($definitions as $definition) {
    $plugin = $this->pluginManager
      ->createInstance($definition['id']);
    $dependency = $plugin
      ->dependency();

    // Ignore plugins if there is a dependency module and it is not enabled.
    if ($dependency && !\Drupal::moduleHandler()
      ->moduleExists($dependency)) {
      continue;
    }

    // Ignore plugins that do not match the specified provider module name.
    if ($provider && $definition['provider'] != $provider) {
      continue;
    }
    $plugins[$plugin
      ->entityType()] = $plugin;
  }

  // Save to the cache only when not filtered for a particular a provider.
  if (empty($provider)) {
    \Drupal::cache()
      ->set('scheduler.plugins', $plugins);
  }
  return $plugins;
}