<?php

declare(strict_types=1);

namespace Drupal\flowdrop_runtime\Event;

use Symfony\Contracts\EventDispatcher\Event;

/**
 * Dispatched when a pipeline is cancelled by an inward Cancel signal.
 *
 * Subscribers can use this to clean up resources, notify external systems,
 * audit log the cancellation, etc. The signal itself has already been
 * acknowledged on the entity by the time this fires; pending outward
 * interrupts on the pipeline have been cancelled.
 *
 * @internal
 */
class ExecutionCancelledEvent extends Event {

  /**
   * The event name.
   */
  const NAME = 'flowdrop_runtime.execution.cancelled';

  /**
   * Constructs a new ExecutionCancelledEvent.
   *
   * @param string $executionId
   *   The execution ID of the cancelled pipeline.
   * @param string $workflowId
   *   The workflow ID.
   * @param string $pipelineId
   *   The pipeline that was cancelled.
   * @param string $signalId
   *   UUID of the Cancel interrupt that triggered the cancellation.
   * @param string|null $reason
   *   The free-form reason the initiator supplied, if any.
   * @param int|null $initiatorUid
   *   The user who raised the Cancel signal, if known.
   */
  public function __construct(
    public readonly string $executionId,
    public readonly string $workflowId,
    public readonly string $pipelineId,
    public readonly string $signalId,
    public readonly ?string $reason,
    public readonly ?int $initiatorUid,
  ) {}

}
