You are here

class ScheduledTransitionsHooks in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x src/ScheduledTransitionsHooks.php \Drupal\scheduled_transitions\ScheduledTransitionsHooks

Hooks for Scheduled Transitions module.

Hierarchy

Expanded class hierarchy of ScheduledTransitionsHooks

2 files declare their use of ScheduledTransitionsHooks
ScheduledTransitionsCronUnitTest.php in tests/src/Unit/ScheduledTransitionsCronUnitTest.php
scheduled_transitions.module in ./scheduled_transitions.module

File

src/ScheduledTransitionsHooks.php, line 14

Namespace

Drupal\scheduled_transitions
View source
class ScheduledTransitionsHooks implements ContainerInjectionInterface {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Job runner for Scheduled Transitions.
   *
   * @var \Drupal\scheduled_transitions\ScheduledTransitionsJobsInterface
   */
  protected $scheduledTransitionsJobs;

  /**
   * Constructs a new ScheduledTransitionsHooks.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
   *   The config factory.
   * @param \Drupal\scheduled_transitions\ScheduledTransitionsJobsInterface $scheduledTransitionsJobs
   *   Job runner for Scheduled Transitions.
   */
  public function __construct(ConfigFactoryInterface $configFactory, ScheduledTransitionsJobsInterface $scheduledTransitionsJobs) {
    $this->configFactory = $configFactory;
    $this->scheduledTransitionsJobs = $scheduledTransitionsJobs;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('config.factory'), $container
      ->get('scheduled_transitions.jobs'));
  }

  /**
   * Implements hook_cron().
   *
   * @see \scheduled_transitions_cron()
   */
  public function cron() : void {
    $settings = $this->configFactory
      ->get('scheduled_transitions.settings');
    if (!empty($settings
      ->get('automation.cron_create_queue_items'))) {
      $this->scheduledTransitionsJobs
        ->jobCreator();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ScheduledTransitionsHooks::$configFactory protected property The config factory.
ScheduledTransitionsHooks::$scheduledTransitionsJobs protected property Job runner for Scheduled Transitions.
ScheduledTransitionsHooks::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
ScheduledTransitionsHooks::cron public function Implements hook_cron().
ScheduledTransitionsHooks::__construct public function Constructs a new ScheduledTransitionsHooks.