-
Notifications
You must be signed in to change notification settings - Fork 43
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
Bug during overrides in configuration #32
Comments
Hi, To disable a state you can do the following: winzou_state_machine:
an_extended_machine:
states:
a_state_to_disable: "::disabled" Is this what you are looking for? It's handled here: https://github.com/winzou/StateMachineBundle/blob/master/DependencyInjection/winzouStateMachineExtension.php#L69 |
Hello, i also experiencing this problem with sylius, now with the beta. i exposed my problem here Sylius/Sylius#7095 And as i said there, the other thing that worked was to put everything on app/config/config.yml and mofiy the Configuration for the State Machine Bundle a little bit. Tried the |
There are indeed different ways of merging symfony configuration. In your case you want to override all the states with your own array of states. But others will want to be able to just add one state, without being forced to rewrite the whole array of states. Both use cases cannot be handled at the same time :) For your use case, you must use the |
Sure, here's the thing. i'm trying to override the states that are defined in this sylius file https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/app/state_machine/sylius_order_checkout.yml As this means There i copied everything and added the winzou_state_machine:
sylius_order_checkout:
class: "%sylius.model.order.class%"
property_path: checkoutState
graph: sylius_order_checkout
state_machine_class: "%sylius.state_machine.class%"
states:
cart: ~
addressed: ~
shipping_selected: '::disabled'
payment_skipped: ~
payment_selected: ~
completed: ~ Now, if try debug the winzou_state_machine and look for that part i get... winzou_state_machine:
sylius_order_checkout:
class: Sylius\Component\Core\Model\Order
property_path: checkoutState
graph: sylius_order_checkout
state_machine_class: Sylius\Component\Resource\StateMachine\StateMachine
states:
cart: null
addressed: null
shipping_selected: '::disabled'
payment_skipped: null
payment_selected: null
completed: null The disabled is there... but my question is... does this means that the state has been really disabled? looking to the sylius documentation it looks like that state shouldn't appear in the output of the debug command at all... Thanks, btw! |
Can you try to execute this command |
Ok, so, having the following in my winzou_state_machine:
sylius_order_checkout:
states:
shipping_selected: '::disabled' executing the command if prompts me what state machine i want to know about and selecting the
Is this the expected behaviour? Thanks. |
Disabling states works for me this way. However, for some reason the first step (also Sylius) I think the issue is this line: As far as I know array_search returns FALSE and not NULL if they entry was not found. Tbh. I don't even understand what this line is supposed to do? |
How does one overrides whole states tree in Symfony4, where bundle configuration override was removed? Is it not possible anymore? |
Well, You can still extend it using packages which basically allows one to disable existing transitions / states like mentioned above in this thread. Of course, it can be done using a CompilerPass or using PrependExtensionInterface However, according to Sylius documentation it should work by placing the file in See: https://docs.sylius.com/en/1.4/cookbook/shop/checkout.html It could be that this is Sylius specific though, I haven't tried it with just Symfony4. However, I think it is the change to the application's kernel here that ensures this works: However, I think it could also work by using the |
@AndreasA thank you, Andreas. It's good to know it still works. |
Yes. But as mentioned, if you are not using Sylius, you might have to make some changes but I guess it should just be (as mentioned above) this overridden method: https://github.com/Sylius/Sylius/blob/1.4/src/Kernel.php#L93 It could probably be done differently too but as long as it works :) |
Hello, any news on this issue ? |
Hi, my workaround is to override winzou\Bundle\StateMachineBundle\DependencyInjection\Configuration class by composer autloader and add $configNode
->arrayNode('transitions')
->useAttributeAsKey('name')
->prototype('array')
->children()
->arrayNode('from')
->performNoDeepMerging()
->prototype('scalar')->end()
->end()
->scalarNode('to')->end()
->end()
->end()
->end()
; |
Hello,
I was trying the new sylius 1.0.0@alpha and tried to disable a state and transitions but it seems that the way that configuration is parsed does not respect overrides and merge all together...
I created test and made a PR, tell me if it seems ok for you and i can create the code to respect this spec
#31
The text was updated successfully, but these errors were encountered: