You are here

public function CronJob::getPlugin in Ultimate Cron 8.2

Get job plugin.

If no plugin name is provided current plugin of the specified type will be returned.

Parameters

string $plugin_type: Name of plugin type.

string $name: (optional) The name of the plugin.

Return value

mixed Plugin instance of the specified type.

Overrides CronJobInterface::getPlugin

3 calls to CronJob::getPlugin()
CronJob::lock in src/Entity/CronJob.php
Lock job.
CronJob::resumeLog in src/Entity/CronJob.php
Resume a previosly saved log.
CronJob::startLog in src/Entity/CronJob.php
Start logging.

File

src/Entity/CronJob.php, line 274

Class

CronJob
Class for handling cron jobs.

Namespace

Drupal\ultimate_cron\Entity

Code

public function getPlugin($plugin_type, $name = NULL) {
  if ($name) {
    return ultimate_cron_plugin_load($plugin_type, $name);
  }

  // @todo: enable static cache, needs unset when values change.
  //    if (isset($this->plugins[$plugin_type])) {
  //      return $this->plugins[$plugin_type];
  //    }
  if ($name) {
  }
  elseif (!empty($this->{$plugin_type}['id'])) {
    $name = $this->{$plugin_type}['id'];
  }
  else {
    $name = $this->hook[$plugin_type]['name'];
  }

  /* @var \Drupal\Core\Plugin\DefaultPluginManager $manager */
  $manager = \Drupal::service('plugin.manager.ultimate_cron.' . $plugin_type);
  $this->plugins[$plugin_type] = $manager
    ->createInstance($name, isset($this->{$plugin_type}['configuration']) ? $this->{$plugin_type}['configuration'] : array());
  return $this->plugins[$plugin_type];
}