<?php

declare(strict_types=1);

namespace Drupal\flowdrop_trigger\Event;

use Drupal\Core\Entity\EntityInterface;
use Drupal\flowdrop_trigger\FlowDropTriggerConfigInterface;
use Drupal\flowdrop_workflow\FlowDropWorkflowInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
 * Event dispatched before a trigger executes.
 *
 * @internal This class is not part of the public API and may change without notice.
 */
class TriggerPreExecuteEvent extends Event {

  /**
   * The event name.
   */
  const NAME = 'flowdrop_trigger.pre_execute';

  /**
   * Constructs a new TriggerPreExecuteEvent.
   *
   * @param \Drupal\flowdrop_trigger\FlowDropTriggerConfigInterface $config
   *   The trigger configuration.
   * @param string $eventType
   *   The event type.
   * @param \Drupal\flowdrop_workflow\FlowDropWorkflowInterface $workflow
   *   The workflow entity.
   * @param \Drupal\Core\Entity\EntityInterface|null $entity
   *   The entity (for entity triggers) or NULL.
   * @param string|null $formId
   *   The form ID (for form triggers) or NULL.
   */
  public function __construct(
    public readonly FlowDropTriggerConfigInterface $config,
    public readonly string $eventType,
    public readonly FlowDropWorkflowInterface $workflow,
    public readonly ?EntityInterface $entity = NULL,
    public readonly ?string $formId = NULL,
  ) {}

}
