Skip to content

Conversation

Guikingone
Copy link
Contributor

By default, the attribute must be an array in order to allow PropertyAccess to update the state and content of this last one, if we need to persist it via Doctrine, the mapping must define an array.

@javiereguiluz
Copy link
Member

@lyrixx could you please review this proposal? Thanks!

@lyrixx
Copy link
Member

lyrixx commented Mar 19, 2018

With a multiple marking store, it's indeed true.
But I'm not very confortable with this doc. The property name is currentPlace:

  1. It's singular, but we says it should be an array
  2. It's not the default name (marking), so it should be configured. Do we really want to overload the "getting started" documentation ?

@Guikingone
Copy link
Contributor Author

@lyrixx In fact, I've noticed this "approach" after trying to persist the attribute, I can understand that it seems strange to do it.

I've don't see that it overload the getting started block ...

Maybe we can rewrite the default name using currentStage or currentPlace and redefine the one which is used here?

@lyrixx
Copy link
Member

lyrixx commented Mar 22, 2018

About the issue:

  • if a MultipleStateMarkingStore is used, the persisted state type should be an array. Or something that could represent many values (json_array, bit fields ...). Usually with doctrine, we use a json or json_array column.
  • if a SingleStateMarkingStore is used, the persisted state type could be a string
  • if something else is used, it's the responsibility of the creator of the "SomeThingElseMarkingStore" to know how to store the data

And juste to make thing really clear, the MarkingStore is not coupled to a Workflow / StateMachine.
A workflow, by nature will require a "MultipleMarkingStore". But if the workflow is "linear", there are not needs for a multiple marking store. But in 99.99% case, it will.
But as a subject managed by a StateMachine can be in only place, a SingleMarkingStore is enough.

@xabbuh xabbuh added this to the 3.4 milestone Apr 20, 2018
@javiereguiluz
Copy link
Member

Sadly this pull request has stalled. Should we reword it, create a different one or close it as "won't merge"? Thanks!

@lyrixx
Copy link
Member

lyrixx commented Apr 25, 2018

This need to be reworded I think ;)

@Guikingone
Copy link
Contributor Author

Yes, I need to have time to work on the reword, I'm gonna take some time this weekend in order to work on this PR.

@javiereguiluz
Copy link
Member

Friendly ping to not forget about this. Thanks!

@Guikingone
Copy link
Contributor Author

@javiereguiluz Yes, need to take time this week to finish this PR.

Fix on the storage format (probably need to be reworded).
Copy link
Contributor

@ndench ndench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for clarifying this.

If a ``multiple_state`` is used, the persisted state type should be an ``array``,
using Doctrine, you can use ``json`` or ``json_array``.

If a ``single_state`` is used, the persisted state type could be a string
Copy link
Contributor

@noniagriconomie noniagriconomie Dec 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or it could be also an integer, but you need to implement a MarkingStoreInterface to convert from string to int the place.

I see more often values of a $status property of object stored as int in the database, not string
Explaining it here could be very usefull to inform that we can do it easily IMO :)

cc @Guikingone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback, I've added new lines about this case, can you review it and tell me if it's adapted? 🤔

Thanks 😊

An improvement has been made in order to explain the usage of an int via MarkingStoreInterface
@javiereguiluz
Copy link
Member

Should we close this pull request without merging it? First, the mentioned json_array type was deprecated in Doctrine. Second, the edge-case mentioned in single_state looks very edgy to me and I don't think we should mention it. Thoughts? Thanks!

@noniagriconomie
Copy link
Contributor

@javiereguiluz

maybe wait symfony/symfony#29146 to be merged? and after document all cases?

but i really think a documentation (with example) is a must have for this part
actually lof of people using the workflow are using it with symfony, and with database storage

having a use case could be a nice one :)

@lyrixx
Copy link
Member

lyrixx commented Jan 2, 2019

No It should not be closed. This PR is good 👍 Let's merge it (except for json_array)

@Guikingone
Copy link
Contributor Author

No It should not be closed. This PR is good 👍 Let's merge it (except for json_array)

We could remove the json_array if it's a problem, not a big deal 😄

If a ``multiple_state`` is used, the persisted state type should be an ``array``,
using Doctrine, you can use ``json`` or ``json_array``.

If a ``single_state`` is used, the persisted state type could be a string,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"could be a string" or "should be a string" ... we say "should be an array" in the previous paragraph.

be aware that you need to implement :class:`Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface`
in order to transform the int back to something understandable by Workflow.

If something else is used, you're in charge of choosing the best storage format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the previous tip related to MarkingStoreInterface apply in this case too? If yes, we must merge these two phrases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz yes it's apply to. So it should be merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Guikingone could you merge theses phrase? Thanks.

After that, IMHO, we will be OK to merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved, to be checked 🙂


.. note::

If a ``multiple_state`` is used, the persisted state type should be an ``array``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prhase needs some reword. It reads as "should be an array using Doctrine". Do you mean, a "PHP array" in the entity property and a "json" type in the @Column mapping?

class BlogPost
{
// This property is used by the marking store
// This property is used by the marking store, by default, Symfony "mark" this attribute as an array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this means --> "Symfony mark this attribute as an array" Is this something that can only be understood if you use the Workflow component (which I don't) ... or is it supposed to be understood by all readers? Thanks!

Copy link
Member

@lyrixx lyrixx Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be this is better:

By default symfony set the marking as an array.

as or with, I don't know

@javiereguiluz
Copy link
Member

@Guikingone please, rebase this to 3.4 so we can merge it. Thank you.

@Guikingone Guikingone force-pushed the patch-8 branch 2 times, most recently from 55b36e1 to d1c0dd0 Compare April 3, 2019 12:15
@Guikingone
Copy link
Contributor Author

@noniagriconomie @lyrixx

Hi 👋

Can you please check one last time this PR before the final rebase, this way, we can close it, thanks :)

@noniagriconomie
Copy link
Contributor

@Guikingone there are some changes/new feature arround this storage part of the workflow
cf symfony/symfony@59f20ad
maybe this PR need to be closed, or adapted

Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. I added few comments.

be aware that you need to implement :class:`Symfony\\Component\\Workflow\\MarkingStore\\MarkingStoreInterface`
in order to transform the int back to something understandable by Workflow.

If something else is used, you're in charge of choosing the best storage format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz yes it's apply to. So it should be merged

Co-Authored-By: Mathieu Santostefano <[email protected]>
.. tip::

The ``type`` (default value ``single_state``) and ``arguments`` (default value ``marking``)
Copy link
Contributor

@noniagriconomie noniagriconomie May 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Guikingone For 4.3+ this need to be removed no?
As single/multiple state are deprecated/removed in favor of method
This PR must be rewrite for method marking store IMO

@lyrixx
Copy link
Member

lyrixx commented Sep 10, 2019

The branch 3.3 is not maintained anymore. And this page does not exist anymore.
Thanks for working on this feature.
I opened #12295 to covert what you trying to achieve.

I thing we can close this PR and iterate on #12295

Thanks again for your work

@OskarStark OskarStark closed this Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants