diff --git a/src/Entity/CronJob.php b/src/Entity/CronJob.php index 4d0cc4f..3dfea56 100644 --- a/src/Entity/CronJob.php +++ b/src/Entity/CronJob.php @@ -1,22 +1,12 @@ classResolver = \Drupal::service('class_resolver'); @@ -271,10 +266,9 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { 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 (isset($this->plugins[$plugin_type])) { + // return $this->plugins[$plugin_type]; + // } if ($name) { } elseif (!empty($this->{$plugin_type}['id'])) { @@ -289,8 +283,16 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { 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'])) { + if (!isset($this->{$plugin_type}['configuration'])) { $this->{$plugin_type}['configuration'] = $this->getPlugin($plugin_type)->defaultConfiguration(); } @@ -385,7 +387,7 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { * * @param string $lock_id * The lock id to unlock. - * @param boolean $manual + * @param bool $manual * Whether or not this is a manual unlock. */ public function unlock($lock_id = NULL, $manual = FALSE) { @@ -459,7 +461,7 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { /** * Get log entries. * - * @param integer $limit + * @param int $limit * (optional) Number of log entries per page. * * @return \Drupal\ultimate_cron\Logger\LogEntry[] @@ -723,11 +725,11 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { $message = (object) array( 'channel' => 'ultimate_cron', 'data' => (object) array( - 'action' => $action, - 'job' => $build, - 'timestamp' => microtime(TRUE), - 'elements' => $elements, - ), + 'action' => $action, + 'job' => $build, + 'timestamp' => microtime(TRUE), + 'elements' => $elements, + ), 'callback' => 'nodejsUltimateCron', ); nodejs_send_content_channel_message($message); @@ -756,11 +758,11 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { * {@inheritdoc} */ public function getCallback() { - if(is_callable($this->callback)) { + if (is_callable($this->callback)) { return $this->callback; } else { - return $this->resolveCallback($this->callback); + return $this->resolveCallback($this->callback); } } @@ -837,6 +839,7 @@ class CronJob extends ConfigEntityBase implements CronJobInterface { */ public function setLoggerId($logger_id) { $this->launcher['id'] = $logger_id; - return $this; + return $this; } + } diff --git a/src/QueueWorker.php b/src/QueueWorker.php index d0a36fc..d5a819e 100644 --- a/src/QueueWorker.php +++ b/src/QueueWorker.php @@ -1,10 +1,5 @@ plugin_manager_queue_worker = $plugin_manager_queue_worker; + $this->pluginManagerQueueWorker = $plugin_manager_queue_worker; $this->queue = $queue; - $this->config_factory = $config_factory; + $this->configFactory = $config_factory; } - + + /** + * Cron callback for queue worker cron jobs. + */ public function queueCallback(CronJobInterface $job) { $queue_name = str_replace(CronJobInterface::QUEUE_ID_PREFIX, '', $job->id()); - $queue_manager = $this->plugin_manager_queue_worker; + $queue_manager = $this->pluginManagerQueueWorker; $queue_factory = $this->queue; - $config = $this->config_factory->get('ultimate_cron.settings'); + $config = $this->configFactory->get('ultimate_cron.settings'); $info = $queue_manager->getDefinition($queue_name); @@ -128,4 +129,5 @@ class QueueWorker { } } } + } diff --git a/ultimate_cron.module b/ultimate_cron.module index 74e05f2..1503578 100755 --- a/ultimate_cron.module +++ b/ultimate_cron.module @@ -5,11 +5,7 @@ */ use Drupal\Core\Queue\RequeueException; -use Drupal\Core\Queue\SuspendQueueException; -use Drupal\ultimate_cron\CronJobInterface; use Drupal\ultimate_cron\CronPlugin; -use Drupal\ultimate_cron\Entity\CronJob; -use Drupal\ultimate_cron\Logger\LoggerBase; use Drupal\ultimate_cron\PluginCleanupInterface; define('ULTIMATE_CRON_LOG_TYPE_NORMAL', 0);