You are here

class CronJob in Ultimate Cron 8.2

Class for handling cron jobs.

This class represents the jobs available in the system.

Plugin annotation


@ConfigEntityType(
  id = "ultimate_cron_job",
  label = @Translation("Cron Job"),
  handlers = {
    "access" = "Drupal\ultimate_cron\CronJobAccessControlHandler",
    "list_builder" = "Drupal\ultimate_cron\CronJobListBuilder",
    "form" = {
      "default" = "Drupal\ultimate_cron\Form\CronJobForm",
      "delete" = "\Drupal\Core\Entity\EntityDeleteForm",
      "disable" = "Drupal\ultimate_cron\Form\CronJobDisableForm",
      "enable" = "Drupal\ultimate_cron\Form\CronJobEnableForm",
    }
  },
  config_prefix = "job",
  admin_permission = "administer ultimate cron",
  entity_keys = {
    "id" = "id",
    "label" = "title",
    "status" = "status",
    "weight" = "weight",
  },
  config_export = {
    "title",
    "id",
    "status",
    "weight",
    "module",
    "callback",
    "scheduler",
    "launcher",
    "logger",
  },
  links = {
    "edit-form" = "/admin/config/system/cron/jobs/manage/{ultimate_cron_job}",
    "delete-form" = "/admin/config/system/cron/jobs/manage/{ultimate_cron_job}/delete",
    "collection" = "/admin/config/system/cron/jobs",
    "run" = "/admin/config/system/cron/jobs/{ultimate_cron_job}/run",
    "disable" = "/admin/config/system/cron/jobs/manage/{ultimate_cron_job}/disable",
    "enable" = "/admin/config/system/cron/jobs/manage/{ultimate_cron_job}/enable",
    "logs" = "/admin/config/system/cron/jobs/logs/{ultimate_cron_job}",
    "unlock" = "/admin/config/system/cron/jobs/{ultimate_cron_job}/unlock",
  }
)

Hierarchy

Expanded class hierarchy of CronJob

20 files declare their use of CronJob
CronJobDiscovery.php in src/CronJobDiscovery.php
CronJobFormTest.php in tests/src/Functional/CronJobFormTest.php
CronJobInstallTest.php in tests/src/Functional/CronJobInstallTest.php
CronJobKernelTest.php in tests/src/Kernel/CronJobKernelTest.php
CronJobTest.php in tests/src/Kernel/CronJobTest.php

... See full list

File

src/Entity/CronJob.php, line 61

Namespace

Drupal\ultimate_cron\Entity
View source
class CronJob extends ConfigEntityBase implements CronJobInterface {
  public static $signals;
  public static $currentJob;
  public $progressUpdated = 0;
  public $settings;

  /**
   * @var int
   */
  protected $id;

  /**
   * @var int
   */
  protected $uuid;

  /**
   * @var bool
   */
  protected $status = TRUE;

  /**
   * The weight.
   *
   * @var int
   */
  protected $weight = 0;

  /**
   * @var string
   */
  protected $title;

  /**
   * @var string
   */
  protected $callback;

  /**
   * @var string
   */
  protected $module;

  /**
   * @var array
   */
  protected $scheduler = array(
    'id' => 'simple',
  );

  /**
   * @var array
   */
  protected $launcher = array(
    'id' => 'serial',
  );

  /**
   * @var array
   */
  protected $logger = array(
    'id' => 'database',
  );

  /**
   * @var \Drupal\ultimate_cron\CronPlugin
   */
  protected $plugins = [];

  /**
   * The class resolver.
   *
   * @var \Drupal\Core\DependencyInjection\ClassResolverInterface
   */
  protected $classResolver;

  /**
   * The module extension list service.
   *
   * @var \Drupal\Core\Extension\ModuleExtensionList
   */
  protected $moduleExtensionList;

  /**
   * CronJob constructor.
   *
   * @param array $values
   * @param string $entity_type
   */
  public function __construct(array $values, $entity_type) {
    parent::__construct($values, $entity_type);
    $this->classResolver = \Drupal::service('class_resolver');
    $this->moduleExtensionList = \Drupal::service('extension.list.module');
  }

  /**
   * {@inheritdoc}
   */
  public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);
    if ($update && empty($this->dont_log)) {
      $log = $this
        ->startLog(uniqid($this
        ->id(), TRUE), '', ULTIMATE_CRON_LOG_TYPE_ADMIN);
      $log
        ->log('Job modified by ' . $log
        ->formatUser(), array(), RfcLogLevel::INFO);
      $log
        ->finish();
    }
  }

  /**
   * Set configuration for a given plugin type.
   *
   * @param string $plugin_type
   *   launcher, logger or scheduler.
   * @param array $configuration
   *   The configuration array.
   */
  public function setConfiguration($plugin_type, array $configuration) {
    $this->{$plugin_type}['configuration'] = $configuration;
  }

  /**
   * {@inheritdoc}
   */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    foreach ($entities as $entity) {
      if (empty($entity->dont_log)) {

        /** @var \Drupal\ultimate_cron\Entity\CronJob $entity */
        $log = $entity
          ->startLog(uniqid($entity
          ->id(), TRUE), 'modification', ULTIMATE_CRON_LOG_TYPE_ADMIN);
        $log
          ->log('Job deleted by ' . $log
          ->formatUser(), array(), RfcLogLevel::INFO);
        $log
          ->finish();
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function isValid() {
    return is_callable($this
      ->getCallback());
  }

  /**
   * Get a signal without affecting it.
   *
   * @see UltimateCronSignal::peek()
   */
  public function peekSignal($signal) {
    if (isset(self::$signals[$this
      ->id()][$signal])) {
      return TRUE;
    }
    $signal = \Drupal::service('ultimate_cron.signal');
    return $signal
      ->peek($this
      ->id(), $signal);
  }

  /**
   * Get a signal and clear it if found.
   *
   * @see UltimateCronSignal::get()
   */
  public function getSignal($signal) {
    if (isset(self::$signals[$this
      ->id()][$signal])) {
      unset(self::$signals[$this
        ->id()][$signal]);
      return TRUE;
    }
    $service = \Drupal::service('ultimate_cron.signal');
    return $service
      ->get($this
      ->id(), $signal);
  }

  /**
   * Send a signal.
   *
   * @see UltimateCronSignal::set()
   */
  public function sendSignal($signal, $persist = FALSE) {
    if ($persist) {
      $signal = \Drupal::service('ultimate_cron.signal');
      $signal
        ->set($this
        ->id(), $signal);
    }
    else {
      self::$signals[$this
        ->id()][$signal] = TRUE;
    }
  }

  /**
   * Clear a signal.
   *
   * @see UltimateCronSignal::clear()
   */
  public function clearSignal($signal) {
    unset(self::$signals[$this
      ->id()][$signal]);
    $signal = \Drupal::service('ultimate_cron.signal');
    $signal
      ->clear($this
      ->id(), $signal);
  }

  /**
   * Send all signal for the job.
   *
   * @see UltimateCronSignal::flush()
   */
  public function clearSignals() {
    unset(self::$signals[$this
      ->id()]);
    $signal = \Drupal::service('ultimate_cron.signal');
    $signal
      ->flush($this
      ->id());
  }

  /**
   * Get job plugin.
   *
   * If no plugin name is provided current plugin of the specified type will
   * be returned.
   *
   * @param string $plugin_type
   *   Name of plugin type.
   * @param string $name
   *   (optional) The name of the plugin.
   *
   * @return mixed
   *   Plugin instance of the specified type.
   */
  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];
  }

  /**
   * Gets this plugin's configuration.
   *
   * @param $plugin_type
   *   The type of plugin.
   * @return array
   *   An array of this plugin's configuration.
   */
  public function getConfiguration($plugin_type) {
    if (!isset($this->{$plugin_type}['configuration'])) {
      $this->{$plugin_type}['configuration'] = $this
        ->getPlugin($plugin_type)
        ->defaultConfiguration();
    }
    return $this->{$plugin_type}['configuration'];
  }

  /**
   * Signal page for plugins.
   */
  public function signal($item, $plugin_type, $plugin_name, $signal) {
    $plugin = ultimate_cron_plugin_load($plugin_type, $plugin_name);
    return $plugin
      ->signal($item, $signal);
  }

  /**
   * Invokes the jobs callback.
   */
  protected function invokeCallback() {
    $callback = $this
      ->getCallback();
    return call_user_func($callback, $this);
  }

  /**
   * Returns a callable for the given controller.
   *
   * @param string $callback
   *   A callback string.
   *
   * @return mixed
   *   A PHP callable.
   *
   * @throws \InvalidArgumentException
   *   If the callback class does not exist.
   */
  protected function resolveCallback($callback) {

    // Controller in the service:method notation.
    $count = substr_count($callback, ':');
    if ($count == 1) {
      list($class_or_service, $method) = explode(':', $callback, 2);
    }
    elseif (strpos($callback, '::') !== FALSE) {
      list($class_or_service, $method) = explode('::', $callback, 2);
    }
    else {
      return $callback;
    }
    $callback = $this->classResolver
      ->getInstanceFromDefinition($class_or_service);
    return array(
      $callback,
      $method,
    );
  }

  /**
   * Check job schedule.
   */
  public function isScheduled() {
    \Drupal::moduleHandler()
      ->invokeAll('cron_pre_schedule', array(
      $this,
    ));
    $result = $this
      ->status() && !$this
      ->isLocked() && $this
      ->getPlugin('scheduler')
      ->isScheduled($this);
    \Drupal::moduleHandler()
      ->invokeAll('cron_post_schedule', array(
      $this,
    ));
    return $result;
  }

  /**
   * Check if job is behind its schedule.
   *
   * @return bool|int
   *   FALSE if job is behind its schedule or number of seconds behind.
   */
  public function isBehindSchedule() {
    return $this
      ->getPlugin('scheduler')
      ->isBehind($this);
  }

  /**
   * Lock job.
   */
  public function lock() {
    $launcher = $this
      ->getPlugin('launcher');
    $lock_id = $launcher
      ->lock($this);
    if (!$lock_id) {
      \Drupal::logger('ultimate_cron')
        ->error('Could not get lock for job @name', array(
        '@name' => $this
          ->id(),
      ));
      return FALSE;
    }
    $this
      ->sendMessage('lock', array(
      'lock_id' => $lock_id,
    ));
    return $lock_id;
  }

  /**
   * Unlock job.
   *
   * @param string $lock_id
   *   The lock id to unlock.
   * @param bool $manual
   *   Whether or not this is a manual unlock.
   */
  public function unlock($lock_id = NULL, $manual = FALSE) {
    $result = NULL;
    if (!$lock_id) {
      $lock_id = $this
        ->isLocked();
    }
    if ($lock_id) {
      $result = $this
        ->getPlugin('launcher')
        ->unlock($lock_id, $manual);
    }
    $this
      ->sendMessage('unlock', array(
      'lock_id' => $lock_id,
    ));
    return $result;
  }

  /**
   * Get locked state of job.
   */
  public function isLocked() {
    return $this
      ->getPlugin('launcher')
      ->isLocked($this);
  }

  /**
   * Get locked state for multiple jobs.
   *
   * @param array $jobs
   *   Jobs to check locks for.
   */
  public static function isLockedMultiple($jobs) {
    $launchers = array();
    foreach ($jobs as $job) {
      $launchers[$job
        ->getPlugin('launcher')->name][$job
        ->id()] = $job;
    }
    $locked = array();
    foreach ($launchers as $launcher => $jobs) {
      $locked += ultimate_cron_plugin_load('launcher', $launcher)
        ->isLockedMultiple($jobs);
    }
    return $locked;
  }

  /**
   * {@inheritdoc}
   */
  public function run($init_message = NULL) {
    if (!$init_message) {
      $init_message = t('Launched manually');
    }
    $lock_id = $this
      ->lock();
    if (!$lock_id) {
      return FALSE;
    }
    $log_entry = $this
      ->startLog($lock_id, $init_message);
    $accountSwitcher = \Drupal::service('account_switcher');
    try {
      $this
        ->clearSignals();
      $this
        ->initializeProgress();
      \Drupal::moduleHandler()
        ->invokeAll('cron_pre_run', array(
        $this,
      ));

      // Force the current user to anonymous to ensure consistent permissions
      // on cron runs.
      $accountSwitcher
        ->switchTo(new AnonymousUserSession());
      self::$currentJob = $this;
      $this
        ->invokeCallback();
    } catch (\Error $e) {

      // PHP 7 throws Error objects in case of a fatal error. It will also call
      // the finally block below and close the log entry. Because of that,
      // the global fatal error catching will not work and we have to log it
      // explicitly here instead. The advantage is that this will not
      // interrupt the process.
      $variables = Error::decodeException($e);
      unset($variables['backtrace']);
      $log_entry
        ->log('%type: @message in %function (line %line of %file).', $variables, RfcLogLevel::ERROR);
      return FALSE;
    } catch (\Exception $e) {
      $variables = Error::decodeException($e);
      unset($variables['backtrace']);
      $log_entry
        ->log('%type: @message in %function (line %line of %file).', $variables, RfcLogLevel::ERROR);
      return FALSE;
    } finally {
      self::$currentJob = NULL;
      \Drupal::moduleHandler()
        ->invokeAll('cron_post_run', array(
        $this,
      ));
      $this
        ->finishProgress();

      // Restore original user account.
      $accountSwitcher
        ->switchBack();
      $log_entry
        ->finish();
      $this
        ->unlock($lock_id);
    }
    return TRUE;
  }

  /**
   * Get log entries.
   *
   * @param int $limit
   *   (optional) Number of log entries per page.
   *
   * @return \Drupal\ultimate_cron\Logger\LogEntry[]
   *   Array of UltimateCronLogEntry objects.
   */
  public function getLogEntries($log_types = ULTIMATE_CRON_LOG_TYPE_ALL, $limit = 10) {
    $log_types = $log_types == ULTIMATE_CRON_LOG_TYPE_ALL ? _ultimate_cron_define_log_type_all() : $log_types;
    return $this
      ->getPlugin('logger')
      ->getLogEntries($this
      ->id(), $log_types, $limit);
  }

  /**
   * Load log entry.
   *
   * @param string $lock_id
   *   The lock id of the log entry.
   *
   * @return LogEntry
   *   The log entry.
   */
  public function loadLogEntry($lock_id) {
    return $this
      ->getPlugin('logger')
      ->load($this
      ->id(), $lock_id);
  }

  /**
   * Load latest log.
   *
   * @return LogEntry
   *   The latest log entry for this job.
   */
  public function loadLatestLogEntry($log_types = array(
    ULTIMATE_CRON_LOG_TYPE_NORMAL,
  )) {
    return $this
      ->getPlugin('logger')
      ->load($this
      ->id(), NULL, $log_types);
  }

  /**
   * Load latest log entries.
   *
   * @param array $jobs
   *   Jobs to load log entries for.
   *
   * @return array
   *   Array of UltimateCronLogEntry objects.
   */
  public static function loadLatestLogEntries($jobs, $log_types = array(
    ULTIMATE_CRON_LOG_TYPE_NORMAL,
  )) {
    $loggers = array();
    foreach ($jobs as $job) {
      $loggers[$job
        ->getPlugin('logger')->name][$job
        ->id()] = $job;
    }
    $log_entries = array();
    foreach ($loggers as $logger => $jobs) {
      $log_entries += ultimate_cron_plugin_load('logger', $logger)
        ->loadLatestLogEntries($jobs, $log_types);
    }
    return $log_entries;
  }

  /**
   * {@inheritdoc}
   */
  public function startLog($lock_id, $init_message = '', $log_type = ULTIMATE_CRON_LOG_TYPE_NORMAL) {
    $logger = $this
      ->getPlugin('logger');
    $log_entry = $logger
      ->createEntry($this
      ->id(), $lock_id, $init_message, $log_type);
    \Drupal::service('logger.ultimate_cron')
      ->catchMessages($log_entry);
    return $log_entry;
  }

  /**
   * Resume a previosly saved log.
   *
   * @param string $lock_id
   *   The lock id of the log to resume.
   *
   * @return LogEntry
   *   The log entry object.
   */
  public function resumeLog($lock_id) {
    $logger = $this
      ->getPlugin('logger');
    $log_entry = $logger
      ->load($this
      ->id(), $lock_id);
    $log_entry->finished = FALSE;
    \Drupal::service('logger.ultimate_cron')
      ->catchMessages($log_entry);
    return $log_entry;
  }

  /**
   * Get module name for this job.
   */
  public function getModuleName() {
    static $names = array();
    if (!isset($names[$this->module])) {
      $info = $this->moduleExtensionList
        ->getExtensionInfo($this->module);
      $names[$this->module] = $info && !empty($info['name']) ? $info['name'] : $this->module;
    }
    return $names[$this->module];
  }

  /**
   * Get module description for this job.
   */
  public function getModuleDescription() {
    static $descs = array();
    if (!isset($descs[$this->module])) {
      $info = $this->moduleExtensionList
        ->getExtensionInfo($this->module);
      $descs[$this->module] = $info && !empty($info['description']) ? $info['description'] : '';
    }
    return $descs[$this->module];
  }

  /**
   * Initialize progress.
   */
  public function initializeProgress() {
    return $this
      ->getPlugin('launcher')
      ->initializeProgress($this);
  }

  /**
   * Finish progress.
   */
  public function finishProgress() {
    return $this
      ->getPlugin('launcher')
      ->finishProgress($this);
  }

  /**
   * Get job progress.
   *
   * @return float
   *   The progress of this job.
   */
  public function getProgress() {
    return $this
      ->getPlugin('launcher')
      ->getProgress($this);
  }

  /**
   * Get multiple job progresses.
   *
   * @param array $jobs
   *   Jobs to get progress for.
   *
   * @return array
   *   Progress of jobs, keyed by job name.
   */
  public static function getProgressMultiple($jobs) {
    $launchers = array();
    foreach ($jobs as $job) {
      $launchers[$job
        ->getPlugin('launcher')->name][$job
        ->id()] = $job;
    }
    $progresses = array();
    foreach ($launchers as $launcher => $jobs) {
      $progresses += ultimate_cron_plugin_load('launcher', $launcher)
        ->getProgressMultiple($jobs);
    }
    return $progresses;
  }

  /**
   * Set job progress.
   *
   * @param float $progress
   *   The progress (0 - 1).
   */
  public function setProgress($progress) {
    if ($this
      ->getPlugin('launcher')
      ->setProgress($this, $progress)) {
      $this
        ->sendMessage('setProgress', array(
        'progress' => $progress,
      ));
      return TRUE;
    }
    return FALSE;
  }

  /**
   * Format progress.
   *
   * @param float $progress
   *   (optional) The progress to format. Uses the progress on the object
   *              if not specified.
   *
   * @return string
   *   Formatted progress.
   */
  public function formatProgress($progress = NULL) {
    if (!isset($progress)) {
      $progress = isset($this->progress) ? $this->progress : $this
        ->getProgress();
    }
    return $this
      ->getPlugin('launcher')
      ->formatProgress($this, $progress);
  }

  /**
   * Get a "unique" id for a job.
   */
  public function getUniqueID() {
    return isset($this->ids[$this
      ->id()]) ? $this->ids[$this
      ->id()] : ($this->ids[$this
      ->id()] = hexdec(substr(sha1($this
      ->id()), -8)));
  }

  /**
   * Send a nodejs message.
   *
   * @param string $action
   *   The action performed.
   * @param array $data
   *   Data blob for the given action.
   */
  public function sendMessage($action, $data = array()) {

    // @TODO: Nodejs integration has not been ported to 8.x yet.
    if (FALSE && \Drupal::moduleHandler()
      ->moduleExists('nodejs')) {
      $settings = ultimate_cron_plugin_load('settings', 'general')
        ->getDefaultSettings();
      if (empty($settings['nodejs'])) {
        return;
      }
      $elements = array();
      $build = clone $this;
      $cell_idxs = array();
      switch ($action) {
        case 'lock':
          $logger = $build
            ->getPlugin('logger');
          if (empty($data['log_entry'])) {
            $build->lock_id = $data['lock_id'];
            $build->log_entry = $logger
              ->factoryLogEntry($build->name);
            $build->log_entry
              ->setData(array(
              'lid' => $data['lock_id'],
              'start_time' => microtime(TRUE),
            ));
          }
          else {
            $build->log_entry = $data['log_entry'];
          }
          $cell_idxs = array(
            'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
            'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
            'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
            'tr#' . $build->name . ' .ctools-export-ui-operations' => 7,
          );
          break;
        case 'unlock':
          $build->log_entry = $build
            ->loadLogEntry($data['lock_id']);
          $build->lock_id = FALSE;
          $cell_idxs = array(
            'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
            'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
            'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
            'tr#' . $build->name . ' .ctools-export-ui-operations' => 7,
          );
          break;
        case 'setProgress':
          $build->lock_id = $build
            ->isLocked();
          $build->log_entry = $build
            ->loadLogEntry($build->lock_id);
          $cell_idxs = array(
            'tr#' . $build->name . ' .ctools-export-ui-start-time' => 3,
            'tr#' . $build->name . ' .ctools-export-ui-duration' => 4,
            'tr#' . $build->name . ' .ctools-export-ui-status' => 5,
          );
          break;
      }
      $cells = $build
        ->rebuild_ctools_export_ui_table_row();
      foreach ($cell_idxs as $selector => $cell_idx) {
        $elements[$selector] = $cells[$cell_idx];
      }
      $message = (object) array(
        'channel' => 'ultimate_cron',
        'data' => (object) array(
          'action' => $action,
          'job' => $build,
          'timestamp' => microtime(TRUE),
          'elements' => $elements,
        ),
        'callback' => 'nodejsUltimateCron',
      );
      nodejs_send_content_channel_message($message);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    parent::calculateDependencies();
    $this
      ->addDependency('module', $this
      ->getModule());
    return $this->dependencies;
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this->title;
  }

  /**
   * {@inheritdoc}
   */
  public function getCallback() {
    if (is_callable($this->callback)) {
      return $this->callback;
    }
    else {
      return $this
        ->resolveCallback($this->callback);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getModule() {
    return $this->module;
  }

  /**
   * {@inheritdoc}
   */
  public function getSchedulerId() {
    return $this->scheduler;
  }

  /**
   * {@inheritdoc}
   */
  public function getLauncherId() {
    return $this->launcher['id'];
  }

  /**
   * {@inheritdoc}
   */
  public function getLoggerId() {
    return $this->logger['id'];
  }

  /**
   * {@inheritdoc}
   */
  public function setTitle($title) {
    $this
      ->set('title', $title);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setCallback($callback) {
    $this
      ->set('callback', $callback);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setModule($module) {
    $this
      ->set('module', $module);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setSchedulerId($scheduler_id) {
    $this->scheduler['id'] = $scheduler_id;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setLauncherId($launcher_id) {
    $this->launcher['id'] = $launcher_id;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setLoggerId($logger_id) {
    $this->logger['id'] = $logger_id;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ConfigEntityBase::$isUninstalling private property Whether the config is being deleted by the uninstall process.
ConfigEntityBase::$langcode protected property The language code of the entity's default language.
ConfigEntityBase::$originalId protected property The original ID of the configuration entity.
ConfigEntityBase::$third_party_settings protected property Third party entity settings.
ConfigEntityBase::$trustedData protected property Trust supplied data and not use configuration schema on save.
ConfigEntityBase::$_core protected property Information maintained by Drupal core about configuration.
ConfigEntityBase::addDependency protected function Overrides \Drupal\Core\Entity\DependencyTrait:addDependency().
ConfigEntityBase::createDuplicate public function Creates a duplicate of the entity. Overrides EntityBase::createDuplicate 1
ConfigEntityBase::disable public function Disables the configuration entity. Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Enables the configuration entity. Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Returns the value of a property. Overrides ConfigEntityInterface::get
ConfigEntityBase::getCacheTagsToInvalidate public function Returns the cache tags that should be used to invalidate caches. Overrides EntityBase::getCacheTagsToInvalidate 1
ConfigEntityBase::getConfigDependencyName public function Gets the configuration dependency name. Overrides EntityBase::getConfigDependencyName
ConfigEntityBase::getConfigManager protected static function Gets the configuration manager.
ConfigEntityBase::getConfigTarget public function Gets the configuration target identifier for the entity. Overrides EntityBase::getConfigTarget
ConfigEntityBase::getDependencies public function Gets the configuration dependencies. Overrides ConfigEntityInterface::getDependencies
ConfigEntityBase::getOriginalId public function Gets the original ID. Overrides EntityBase::getOriginalId
ConfigEntityBase::getThirdPartyProviders public function Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface::getThirdPartyProviders
ConfigEntityBase::getThirdPartySetting public function Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface::getThirdPartySetting
ConfigEntityBase::getThirdPartySettings public function Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface::getThirdPartySettings
ConfigEntityBase::getTypedConfig protected function Gets the typed config manager.
ConfigEntityBase::hasTrustedData public function Gets whether on not the data is trusted. Overrides ConfigEntityInterface::hasTrustedData
ConfigEntityBase::invalidateTagsOnDelete protected static function Override to never invalidate the individual entities' cache tags; the config system already invalidates them. Overrides EntityBase::invalidateTagsOnDelete
ConfigEntityBase::invalidateTagsOnSave protected function Override to never invalidate the entity's cache tag; the config system already invalidates it. Overrides EntityBase::invalidateTagsOnSave
ConfigEntityBase::isInstallable public function Checks whether this entity is installable. Overrides ConfigEntityInterface::isInstallable 2
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides EntityBase::isNew
ConfigEntityBase::isUninstalling public function Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface::isUninstalling
ConfigEntityBase::link public function Deprecated way of generating a link to the entity. See toLink(). Overrides EntityBase::link
ConfigEntityBase::onDependencyRemoval public function Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityInterface::onDependencyRemoval 7
ConfigEntityBase::preDelete public static function Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase::preDelete 8
ConfigEntityBase::preSave public function Acts on an entity before the presave hook is invoked. Overrides EntityBase::preSave 13
ConfigEntityBase::save public function Saves an entity permanently. Overrides EntityBase::save 1
ConfigEntityBase::set public function Sets the value of a property. Overrides ConfigEntityInterface::set
ConfigEntityBase::setOriginalId public function Sets the original ID. Overrides EntityBase::setOriginalId
ConfigEntityBase::setStatus public function Sets the status of the configuration entity. Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::setThirdPartySetting public function Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface::setThirdPartySetting
ConfigEntityBase::setUninstalling public function
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 6
ConfigEntityBase::status public function Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface::status 4
ConfigEntityBase::toArray public function Gets an array of all property values. Overrides EntityBase::toArray 2
ConfigEntityBase::toUrl public function Gets the URL object for the entity. Overrides EntityBase::toUrl
ConfigEntityBase::trustData public function Sets that the data should be trusted. Overrides ConfigEntityInterface::trustData
ConfigEntityBase::unsetThirdPartySetting public function Unsets a third-party setting. Overrides ThirdPartySettingsInterface::unsetThirdPartySetting
ConfigEntityBase::url public function Gets the public URL for this entity. Overrides EntityBase::url
ConfigEntityBase::urlInfo public function Gets the URL object for the entity. Overrides EntityBase::urlInfo
ConfigEntityBase::__sleep public function Overrides EntityBase::__sleep 4
CronJob::$callback protected property
CronJob::$classResolver protected property The class resolver.
CronJob::$currentJob public static property
CronJob::$id protected property
CronJob::$launcher protected property
CronJob::$logger protected property
CronJob::$module protected property
CronJob::$moduleExtensionList protected property The module extension list service.
CronJob::$plugins protected property
CronJob::$progressUpdated public property
CronJob::$scheduler protected property
CronJob::$settings public property
CronJob::$signals public static property
CronJob::$status protected property Overrides ConfigEntityBase::$status
CronJob::$title protected property
CronJob::$uuid protected property Overrides ConfigEntityBase::$uuid
CronJob::$weight protected property The weight.
CronJob::calculateDependencies public function Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityBase::calculateDependencies
CronJob::clearSignal public function Clear a signal. Overrides CronJobInterface::clearSignal
CronJob::clearSignals public function Send all signal for the job. Overrides CronJobInterface::clearSignals
CronJob::finishProgress public function Finish progress. Overrides CronJobInterface::finishProgress
CronJob::formatProgress public function Format progress. Overrides CronJobInterface::formatProgress
CronJob::getCallback public function Gets the cron job callback string. Overrides CronJobInterface::getCallback
CronJob::getConfiguration public function Gets this plugin's configuration.
CronJob::getLauncherId public function Gets launcher array which holds info about the launcher settings. Overrides CronJobInterface::getLauncherId
CronJob::getLogEntries public function Get log entries. Overrides CronJobInterface::getLogEntries
CronJob::getLoggerId public function Gets logger array which holds info about the logger settings. Overrides CronJobInterface::getLoggerId
CronJob::getModule public function Gets the cron job module name used for the callback string. Overrides CronJobInterface::getModule
CronJob::getModuleDescription public function Get module description for this job. Overrides CronJobInterface::getModuleDescription
CronJob::getModuleName public function Get module name for this job. Overrides CronJobInterface::getModuleName
CronJob::getPlugin public function Get job plugin. Overrides CronJobInterface::getPlugin
CronJob::getProgress public function Get job progress. Overrides CronJobInterface::getProgress
CronJob::getProgressMultiple public static function Get multiple job progresses. Overrides CronJobInterface::getProgressMultiple
CronJob::getSchedulerId public function Gets scheduler array which holds info about the scheduler settings. Overrides CronJobInterface::getSchedulerId
CronJob::getSignal public function Get a signal and clear it if found. Overrides CronJobInterface::getSignal
CronJob::getTitle public function Gets the title of the created cron job. Overrides CronJobInterface::getTitle
CronJob::getUniqueID public function Get a "unique" id for a job. Overrides CronJobInterface::getUniqueID
CronJob::initializeProgress public function Initialize progress. Overrides CronJobInterface::initializeProgress
CronJob::invokeCallback protected function Invokes the jobs callback.
CronJob::isBehindSchedule public function Check if job is behind its schedule. Overrides CronJobInterface::isBehindSchedule
CronJob::isLocked public function Get locked state of job. Overrides CronJobInterface::isLocked
CronJob::isLockedMultiple public static function Get locked state for multiple jobs. Overrides CronJobInterface::isLockedMultiple
CronJob::isScheduled public function Check job schedule. Overrides CronJobInterface::isScheduled
CronJob::isValid public function Check if the cron job is callable. Overrides CronJobInterface::isValid
CronJob::loadLatestLogEntries public static function Load latest log entries. Overrides CronJobInterface::loadLatestLogEntries
CronJob::loadLatestLogEntry public function Load latest log. Overrides CronJobInterface::loadLatestLogEntry
CronJob::loadLogEntry public function Load log entry. Overrides CronJobInterface::loadLogEntry
CronJob::lock public function Lock job. Overrides CronJobInterface::lock
CronJob::peekSignal public function Get a signal without affecting it. Overrides CronJobInterface::peekSignal
CronJob::postDelete public static function Acts on deleted entities before the delete hook is invoked. Overrides EntityBase::postDelete
CronJob::postSave public function Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase::postSave
CronJob::resolveCallback protected function Returns a callable for the given controller.
CronJob::resumeLog public function Resume a previosly saved log. Overrides CronJobInterface::resumeLog
CronJob::run public function Run job. Overrides CronJobInterface::run
CronJob::sendMessage public function Send a nodejs message.
CronJob::sendSignal public function Send a signal. Overrides CronJobInterface::sendSignal
CronJob::setCallback public function Sets the cron job callback string. Overrides CronJobInterface::setCallback
CronJob::setConfiguration public function Set configuration for a given plugin type.
CronJob::setLauncherId public function Sets launcher array which holds info about the launcher settings. Overrides CronJobInterface::setLauncherId
CronJob::setLoggerId public function Sets logger array which holds info about the logger settings. Overrides CronJobInterface::setLoggerId
CronJob::setModule public function Sets the cron job module name used for the callback string. Overrides CronJobInterface::setModule
CronJob::setProgress public function Set job progress. Overrides CronJobInterface::setProgress
CronJob::setSchedulerId public function Sets scheduler array which holds info about the scheduler settings. Overrides CronJobInterface::setSchedulerId
CronJob::setTitle public function Sets the title of the created cron job. Overrides CronJobInterface::setTitle
CronJob::signal public function Signal page for plugins.
CronJob::startLog public function Start logging. Overrides CronJobInterface::startLog
CronJob::unlock public function Unlock job. Overrides CronJobInterface::unlock
CronJob::__construct public function CronJob constructor. Overrides ConfigEntityBase::__construct
CronJobInterface::QUEUE_ID_PREFIX constant Cron job ID prefix for queue jobs.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function Aliased as: traitSleep 1
DependencySerializationTrait::__wakeup public function 2
DependencyTrait::$dependencies protected property The object's dependencies.
DependencyTrait::addDependencies protected function Adds multiple dependencies.
DependencyTrait::addDependency protected function Adds a dependency. Aliased as: addDependencyTrait
EntityBase::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
EntityBase::$entityTypeId protected property The entity type.
EntityBase::$typedData protected property A typed data object wrapping this entity.
EntityBase::access public function Checks data value access. Overrides AccessibleInterface::access 1
EntityBase::bundle public function Gets the bundle of the entity. Overrides EntityInterface::bundle 1
EntityBase::create public static function Constructs a new entity object, without permanently saving it. Overrides EntityInterface::create
EntityBase::delete public function Deletes an entity permanently. Overrides EntityInterface::delete 2
EntityBase::enforceIsNew public function Enforces an entity to be new. Overrides EntityInterface::enforceIsNew
EntityBase::entityManager Deprecated protected function Gets the entity manager.
EntityBase::entityTypeBundleInfo protected function Gets the entity type bundle info service.
EntityBase::entityTypeManager protected function Gets the entity type manager.
EntityBase::getCacheContexts public function The cache contexts associated with this object. Overrides CacheableDependencyTrait::getCacheContexts
EntityBase::getCacheMaxAge public function The maximum age for which this object may be cached. Overrides CacheableDependencyTrait::getCacheMaxAge
EntityBase::getCacheTags public function The cache tags associated with this object. Overrides CacheableDependencyTrait::getCacheTags
EntityBase::getConfigDependencyKey public function Gets the key that is used to store configuration dependencies. Overrides EntityInterface::getConfigDependencyKey
EntityBase::getEntityType public function Gets the entity type definition. Overrides EntityInterface::getEntityType
EntityBase::getEntityTypeId public function Gets the ID of the type of the entity. Overrides EntityInterface::getEntityTypeId
EntityBase::getListCacheTagsToInvalidate protected function The list cache tags to invalidate for this entity.
EntityBase::getTypedData public function Gets a typed data object for this entity object. Overrides EntityInterface::getTypedData
EntityBase::hasLinkTemplate public function Indicates if a link template exists for a given key. Overrides EntityInterface::hasLinkTemplate
EntityBase::id public function Gets the identifier. Overrides EntityInterface::id 11
EntityBase::label public function Gets the label of the entity. Overrides EntityInterface::label 6
EntityBase::language public function Gets the language of the entity. Overrides EntityInterface::language 1
EntityBase::languageManager protected function Gets the language manager.
EntityBase::linkTemplates protected function Gets an array link templates. 1
EntityBase::load public static function Loads an entity. Overrides EntityInterface::load
EntityBase::loadMultiple public static function Loads one or more entities. Overrides EntityInterface::loadMultiple
EntityBase::postCreate public function Acts on a created entity before hooks are invoked. Overrides EntityInterface::postCreate 4
EntityBase::postLoad public static function Acts on loaded entities. Overrides EntityInterface::postLoad 2
EntityBase::preCreate public static function Changes the values of an entity before it is created. Overrides EntityInterface::preCreate 5
EntityBase::referencedEntities public function Gets a list of entities referenced by this entity. Overrides EntityInterface::referencedEntities 1
EntityBase::toLink public function Generates the HTML for a link to this entity. Overrides EntityInterface::toLink
EntityBase::uriRelationships public function Gets a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
EntityBase::urlRouteParameters protected function Gets an array of placeholders for this entity. 2
EntityBase::uuid public function Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface::uuid 1
EntityBase::uuidGenerator protected function Gets the UUID generator.
PluginDependencyTrait::calculatePluginDependencies protected function Calculates and adds dependencies of a specific plugin instance. 1
PluginDependencyTrait::getPluginDependencies protected function Calculates and returns dependencies of a specific plugin instance.
PluginDependencyTrait::moduleHandler protected function Wraps the module handler. 1
PluginDependencyTrait::themeHandler protected function Wraps the theme handler. 1
RefinableCacheableDependencyTrait::addCacheableDependency public function 1
RefinableCacheableDependencyTrait::addCacheContexts public function
RefinableCacheableDependencyTrait::addCacheTags public function
RefinableCacheableDependencyTrait::mergeCacheMaxAge public function
SynchronizableEntityTrait::$isSyncing protected property Whether this entity is being created, updated or deleted through a synchronization process.
SynchronizableEntityTrait::isSyncing public function
SynchronizableEntityTrait::setSyncing public function