{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/27925","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/27925/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/27925/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/27925/events","html_url":"https://github.com/symfony/symfony/issues/27925","id":340186768,"node_id":"MDU6SXNzdWUzNDAxODY3Njg=","number":27925,"title":"[WORKFLOW] [RFC] Pass context/metadata in the entire workflow process","user":{"login":"noniagriconomie","id":13205768,"node_id":"MDQ6VXNlcjEzMjA1NzY4","avatar_url":"https://avatars1.githubusercontent.com/u/13205768?v=4","gravatar_id":"","url":"https://api.github.com/users/noniagriconomie","html_url":"https://github.com/noniagriconomie","followers_url":"https://api.github.com/users/noniagriconomie/followers","following_url":"https://api.github.com/users/noniagriconomie/following{/other_user}","gists_url":"https://api.github.com/users/noniagriconomie/gists{/gist_id}","starred_url":"https://api.github.com/users/noniagriconomie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noniagriconomie/subscriptions","organizations_url":"https://api.github.com/users/noniagriconomie/orgs","repos_url":"https://api.github.com/users/noniagriconomie/repos","events_url":"https://api.github.com/users/noniagriconomie/events{/privacy}","received_events_url":"https://api.github.com/users/noniagriconomie/received_events","type":"User","site_admin":false},"labels":[{"id":83934034,"node_id":"MDU6TGFiZWw4MzkzNDAzNA==","url":"https://api.github.com/repos/symfony/symfony/labels/RFC","name":"RFC","color":"fbca04","default":false},{"id":397995968,"node_id":"MDU6TGFiZWwzOTc5OTU5Njg=","url":"https://api.github.com/repos/symfony/symfony/labels/Workflow","name":"Workflow","color":"dddddd","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":16,"created_at":"2018-07-11T10:39:29Z","updated_at":"2018-10-04T15:44:40Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"**Description**  \r\n\r\nHi\r\n\r\nWe are using the workflow component to redesign our internal processing of some business entities.\r\n\r\nWe are now facing some logic we did not know how to deal with on our code port.\r\n\r\nPreviously we were doing on our entities status change this logic:\r\n\r\n```php\r\n$entity->setStatus(Entity::STATUS_X, $specificComment); // comment can be a tech comment, a context comment, or anything else\r\n```\r\n\r\nand the setStatus() method is like this\r\n\r\n```php\r\npublic function setStatus(int $status, ?string $comment = null)\r\n{\r\n        $this->status = $status;\r\n        $this->addStatusLogRecord(new StatusLog($this, $comment));\r\n\r\n        return $this;\r\n}\r\n```\r\n\r\nWe were storing a statusLog on every status change with the new status, the date of change, the user (blameable) and an optionnal comment => for log/debug/history purpose\r\n\r\nBut now with the workflow, it is our internal marking store that call the `setStatus()` (mapping of the current place to our internal status because we store an int not a string), \r\nand unfortunately we are not able to pass some other metadata.\r\n\r\n**Feature Request**  \r\n\r\nDiscussion on the availability to have a workflow business context to allow the developper to pass some context in the workflow process, \r\nand get this context inside the workflow process, all workflow events and in the workflow marking store logic as well.\r\nIs this a feature that can be usefull for this component? giving some possibility to developpers?\r\nOr maybe developpers are already dealing differently for this kind of purpose?\r\n\r\nObviously we can add an in memory property on the entity for storing the comment and if it is not null, get it for the `addStatusLogRecord()` but this design is not pleasant at all.\r\n\r\nMany thank for your time and thank you for this component that helps us a lot"},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/427068601","html_url":"https://github.com/symfony/symfony/issues/27925#issuecomment-427068601","issue_url":"https://api.github.com/repos/symfony/symfony/issues/27925","id":427068601,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNzA2ODYwMQ==","user":{"login":"SulivanDotEu","id":3897363,"node_id":"MDQ6VXNlcjM4OTczNjM=","avatar_url":"https://avatars0.githubusercontent.com/u/3897363?v=4","gravatar_id":"","url":"https://api.github.com/users/SulivanDotEu","html_url":"https://github.com/SulivanDotEu","followers_url":"https://api.github.com/users/SulivanDotEu/followers","following_url":"https://api.github.com/users/SulivanDotEu/following{/other_user}","gists_url":"https://api.github.com/users/SulivanDotEu/gists{/gist_id}","starred_url":"https://api.github.com/users/SulivanDotEu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SulivanDotEu/subscriptions","organizations_url":"https://api.github.com/users/SulivanDotEu/orgs","repos_url":"https://api.github.com/users/SulivanDotEu/repos","events_url":"https://api.github.com/users/SulivanDotEu/events{/privacy}","received_events_url":"https://api.github.com/users/SulivanDotEu/received_events","type":"User","site_admin":false},"created_at":"2018-10-04T15:44:40Z","updated_at":"2018-10-04T15:44:40Z","author_association":"NONE","body":"+1\r\nI'm facing many cases where I miss this feature.\r\n\r\nHere is an example:\r\n\r\nLet's take an auction as exemple described in _workflow.yaml_ below. The auction is simple, user can create an auction but only an admin can start the auction. After that, each user can bid only one to an auction. Also, to be able to bid, you must have an active membership. pretty simple business logic.\r\n\r\n```\r\nframework:\r\n    workflows:\r\n        auction:\r\n            type: state_machine\r\n            marking_store:\r\n                type: single_state\r\n                arguments:\r\n                    - status\r\n            supports:\r\n                - App\\Entity\\Auction\r\n            places:\r\n                - draft\r\n                - started\r\n                - ended\r\n            transitions:\r\n                start:\r\n                    from: draft\r\n                    to:     submitted\r\n                    metadata:\r\n                        roles: [ROLE_ADMIN, ROLE_SUPERADMIN]\r\n                make_an_offer:\r\n                    from: started\r\n                    to:     started\r\n                    metadata:\r\n                        roles: [ROLE_USER]\r\n```\r\n\r\n\r\nThanks to the metadata, I can specify which role is required to start an auction. Fine it as been put in place.\r\nSecondly, I would like to validate that a user can \"make an offer\". For that, I will use the method `Workflow::can($auction, 'make_an_offer', ['user' => $user])` .\r\nFrom there, I can create a guard that will check if that current user already bid or not on the auction.\r\nI really miss this feature and any alternative seems to be so expensive so far. Still thinking about alternatives."}}
{"actor":{"display_login":"SulivanDotEu"}}