-
-
Notifications
You must be signed in to change notification settings - Fork 94
Link order generation to state machine #283
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
base: 1.0
Are you sure you want to change the base?
Changes from 2 commits
1b76e14
a817d69
380941a
7e36063
3ec77e8
f77bc23
3c3a1fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,16 +35,16 @@ public function __construct( | |||||||||
| ) { | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public function __invoke(string $orderNumber, \DateTimeInterface $dateTime): void | ||||||||||
| public function __invoke(int $orderId, \DateTimeInterface $dateTime): void | ||||||||||
| { | ||||||||||
| /** @var OrderInterface $order */ | ||||||||||
| $order = $this->orderRepository->findOneByNumber($orderNumber); | ||||||||||
| $order = $this->orderRepository->find($orderId); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried this before but it didn't work, I'll try again.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Behat test is maybe missing something, in my current projet I have to prepare my order doing this : $stateMachine = $this->stateMachineFactory->get($order, OrderTransitions::GRAPH);
$stateMachine->apply(OrderTransitions::TRANSITION_CREATE);save it to the database and complete the order ( |
||||||||||
|
|
||||||||||
| /** @var InvoiceInterface|null $invoice */ | ||||||||||
| $invoice = $this->invoiceRepository->findOneByOrder($order); | ||||||||||
|
|
||||||||||
| if (null !== $invoice) { | ||||||||||
| throw InvoiceAlreadyGenerated::withOrderNumber($orderNumber); | ||||||||||
| throw InvoiceAlreadyGenerated::withOrderId($orderId); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| $invoice = $this->invoiceGenerator->generateForOrder($order, $dateTime); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,13 @@ winzou_state_machine: | |
| on: ['complete'] | ||
| do: ['@sylius_invoicing_plugin.event_producer.order_payment_paid', '__invoke'] | ||
| args: ['object'] | ||
| sylius_order: | ||
| callbacks: | ||
| after: | ||
| sylius_invoicing_plugin_order_placed_producer: | ||
| on: ['create'] | ||
| do: ['@sylius_invoicing_plugin.event_producer.order_placed', '__invoke'] | ||
| args: ['object'] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading what the
Don't you think the new callback should be set on the state machine named :
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll try this, and check if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The order number is assigned here : https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/app/state_machine/sylius_order.yml#L26
Comment on lines
+28
to
+34
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it wouldn't be better to put this logic on the callback after
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @Prometee
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GSadee yes it will make the same thing, but one issue will happen here if the $order = $this->orderFactory->createNew();
/* add product, address and select payment, shipping etc */
$this->stateMachineFactory
->get($order, OrderCheckoutTransitions::GRAPH)
->apply(OrderCheckoutTransitions::TRANSITION_COMPLETE)
;The result will be an error on the To solve this, the I know it's a big change and it will make useless triggering the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I correctly understand you, is there a problem with moving the callback to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my point of view the |
||
|
|
||
| sylius_grid: | ||
| templates: | ||
|
|
||
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.
This phpdoc is missing the possibility of
null