-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove missed sm.factory usages #15858
Remove missed sm.factory usages #15858
Conversation
Bunnyshell Preview Environment deletedAvailable commands:
|
edb70ff
to
b1daaae
Compare
src/Sylius/Bundle/ApiBundle/Applicator/OrderStateMachineTransitionApplicator.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Applicator/ProductReviewStateMachineTransitionApplicator.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/EventListener/Workflow/Order/CancelOrderPaymentListener.php
Show resolved
Hide resolved
src/Sylius/Abstraction/StateMachine/src/CompositeStateMachine.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Exception/OrderCancellationFailedException.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Applicator/PaymentStateMachineTransitionApplicator.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/spec/EventListener/Workflow/Order/CreatePaymentListenerSpec.php
Outdated
Show resolved
Hide resolved
$this->getStateMachine()->apply($review, ProductReviewTransitions::GRAPH, $transition); | ||
$stateMachine = $this->getStateMachine(); | ||
|
||
if (false === $stateMachine->can($review, ProductReviewTransitions::GRAPH, $transition)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it better this way instead of just using a simple try-catch block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the try-catch
block catches all exceptions from the Symfony workflow, and the method can
only checks if a transition is possible. In the try-catch
block, we always receive the same exception, whereas in the second case, we receive different exceptions if the method apply
throws an exception.
Thank you, @Wojdylak! |
The
apply
method in the sm.callback.cascade_transition class (\SM\Callback\CascadeTransitionCallback) has a$soft
parameter, which defaults to true. When$soft
is set to true, the method first checks if the transition can be applied without throwing an exception. So I have added checking to symfony workflow events.