From e4b6d594148382709c2fbc2838fed08b9ad267d4 Mon Sep 17 00:00:00 2001 From: Bart Jaskulski <bjaskulski@protonmail.com> Date: Wed, 27 Nov 2024 15:41:15 +0100 Subject: [PATCH] fix: improve the work of stoppable binder Previously stoppable binder was working for all binders, although it only supported to signal stop execution with class-based binders. This changes the behavior, as having all binders wrapped in stoppable binder resulted in execution of all collection binders, without regard for the stop signal. This is convoluted and gets even worse, so this part of the API should be rewritten. The side effect of this change is that any callable based binder (e.g. database migrations) will not be stopped, no matter what happens. This is a serious quirk, and may be better to remove other kinds of binders than hookable or rethink the stoppable binder. Signed-off-by: Bart Jaskulski <bjaskulski@protonmail.com> --- src/Binding/Binder/StoppableBinder.php | 1 - src/Kernel.php | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Binding/Binder/StoppableBinder.php b/src/Binding/Binder/StoppableBinder.php index d1b1500..b18bb06 100644 --- a/src/Binding/Binder/StoppableBinder.php +++ b/src/Binding/Binder/StoppableBinder.php @@ -9,7 +9,6 @@ use WPDesk\Init\Binding\ComposableBinder; use WPDesk\Init\Binding\StoppableBinder as Stop; use WPDesk\Init\Binding\Definition; use WPDesk\Init\Binding\Binder as BinderInstance; -use WPDesk\Init\Binding\Definition\HookableDefinition; class StoppableBinder implements ComposableBinder { diff --git a/src/Kernel.php b/src/Kernel.php index 0f6cbeb..75e48cc 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -7,7 +7,6 @@ use DI\Container; use DI\ContainerBuilder as DiBuilder; use Psr\Container\ContainerInterface; use WPDesk\Init\Binding\Binder\CallableBinder; -use WPDesk\Init\Binding\Binder\CollectionBinder; use WPDesk\Init\Binding\Binder\CompositeBinder; use WPDesk\Init\Binding\Binder\HookableBinder; use WPDesk\Init\Binding\Binder\StoppableBinder; @@ -132,12 +131,9 @@ final class Kernel { $driver = new GenericDriver( $loader, - new StoppableBinder( - new CompositeBinder( - new HookableBinder( $container ), - new CallableBinder( $container ) - ), - $container + new CompositeBinder( + new StoppableBinder( new HookableBinder( $container ), $container ), + new CallableBinder( $container ) ) ); -- GitLab