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-&gt;createInterrupt(<br>&nbsp; InterruptType::Confirmation,<br>&nbsp; $workflowId,<br>&nbsp; $nodeId,<br>&nbsp; 'Approve?',<br>&nbsp; schema: ['type' =&gt; 'boolean', 'presentation' =&gt; 'confirmation'],<br>&nbsp; pipeline_id: $pipelineId,<br>);<br>throw new InterruptRequiredException($interrupt);<br><br>// Reading the entity off the exception.<br>try {<br>&nbsp; // ...<br>}<br>catch (InterruptRequiredException $e) {<br>&nbsp; $entity = $e-&gt;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>&nbsp; message: 'Approve?',<br>&nbsp; schema: ['type' =&gt; 'boolean', 'presentation' =&gt; 'confirmation'],<br>));<br><br>// Or, for code that must create synchronously, use the factory.<br>$interrupt = $interruptFactory-&gt;create(new InterruptCreationData(<br>&nbsp; type: InterruptType::Confirmation,<br>&nbsp; workflowId: $workflowId,<br>&nbsp; nodeId: $nodeId,<br>&nbsp; message: 'Approve?',<br>&nbsp; schema: ['type' =&gt; 'boolean', 'presentation' =&gt; 'confirmation'],<br>&nbsp; pipelineId: $pipelineId,<br>));<br><br>// Reading the entity off the exception.<br>try {<br>&nbsp; // ...<br>}<br>catch (InterruptRequiredException $e) {<br>&nbsp; $entity = $e-&gt;getInterrupt();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // entity-shape, or NULL for<br>message-shape<br>&nbsp; $message = $e-&gt;getInterruptMessage();&nbsp; // message DTO, or NULL for entity-shape<br>}</pre><h2>Notes</h2> <ul> <li>Calling createInterrupt() triggers E_USER_DEPRECATED. Reading $exception-&gt;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