Deprecate InterruptManagerInterface::createInterrupt() and InterruptRequiredException::$interrupt
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3591539. -->
Reported by: [d34dman](https://www.drupal.org/user/751698)
>>>
<h2>Summary<br>
</h2>
<p>Two surfaces on <code>flowdrop_interrupt</code> are deprecated in <code>1.4.0</code> and will be removed in <code>2.0.0</code>:</p>
<ol>
<li><code>\Drupal\flowdrop_interrupt\Service\InterruptManagerInterface::createInterrupt()</code></li>
<li><code>\Drupal\flowdrop_interrupt\Exception\InterruptRequiredException::$interrupt</code> (public readonly property)</li>
</ol>
<h2>Why</h2>
<p>Interrupts now flow through a message bus. A node processor throws<br>
InterruptRequiredException with an InterruptMessage DTO, and the catch-side<br>
subscriber persists the entity and dispatches it on JobInterruptCaughtEvent. The<br>
synchronous createInterrupt() method and the entity-only $interrupt property<br>
predate that design.</p>
<p>Before (1.3.x)</p>
<pre>// Creating an interrupt synchronously.<br>$interrupt = $interruptManager->createInterrupt(<br> InterruptType::Confirmation,<br> $workflowId,<br> $nodeId,<br> 'Approve?',<br> schema: ['type' => 'boolean', 'presentation' => 'confirmation'],<br> pipeline_id: $pipelineId,<br>);<br>throw new InterruptRequiredException($interrupt);<br><br>// Reading the entity off the exception.<br>try {<br> // ...<br>}<br>catch (InterruptRequiredException $e) {<br> $entity = $e->interrupt;<br>}</pre><p>
After (1.4.x+)</p>
<pre>// Preferred: throw with a message DTO and let the bus persist it.<br>throw new InterruptRequiredException(new HitlInterruptMessage(<br> message: 'Approve?',<br> schema: ['type' => 'boolean', 'presentation' => 'confirmation'],<br>));<br><br>// Or, for code that must create synchronously, use the factory.<br>$interrupt = $interruptFactory->create(new InterruptCreationData(<br> type: InterruptType::Confirmation,<br> workflowId: $workflowId,<br> nodeId: $nodeId,<br> message: 'Approve?',<br> schema: ['type' => 'boolean', 'presentation' => 'confirmation'],<br> pipelineId: $pipelineId,<br>));<br><br>// Reading the entity off the exception.<br>try {<br> // ...<br>}<br>catch (InterruptRequiredException $e) {<br> $entity = $e->getInterrupt(); // entity-shape, or NULL for<br>message-shape<br> $message = $e->getInterruptMessage(); // message DTO, or NULL for entity-shape<br>}</pre><h2>Notes</h2>
<ul>
<li>Calling createInterrupt() triggers E_USER_DEPRECATED. Reading $exception->interrupt does not (PHP can't intercept readonly property reads); rely on the @deprecated annotation and static analysis to surface it.</li>
<li>The 1.3.0 createInterrupt() signature is preserved exactly, so call sites do not need updating to keep working in 1.4.x.</li>
<li>Plan to migrate before 2.0.0.</li>
</ul>
issue