Feature: Updating Listreners, Separating Logic from listeners, Queuing Policies
This commit is contained in:
@@ -133,6 +133,22 @@ class OrderStatusFlow
|
||||
return ! $order->paid && $this->isCod($order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether moving $order to $to is a valid transition from its CURRENT
|
||||
* status — the single source of truth for "is this a legal next step,"
|
||||
* so a caller reacting to an external event (a carrier tracking
|
||||
* checkpoint, a staff action) doesn't need to hardcode its own "only
|
||||
* fire from status X" guard duplicating what nextOptions() already
|
||||
* knows. See e.g. Modules\Core\Order\Listeners\
|
||||
* AdvanceFulfillmentOnCarrierCheckpoint, which used to compare
|
||||
* $order->status to a literal 'ready_for_dispatch' inline instead of
|
||||
* asking this class.
|
||||
*/
|
||||
public function isValidTransition(Order $order, string $to): bool
|
||||
{
|
||||
return array_key_exists($to, $this->nextOptions($order));
|
||||
}
|
||||
|
||||
private function label(string $status): string
|
||||
{
|
||||
return (string) str($status)->replace('_', ' ')->title();
|
||||
|
||||
Reference in New Issue
Block a user