-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Workflow] Added DefinitionInterface #20441
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
Conversation
I'm sorry, but I fail to see why adding this interface will allow us to introduce an More over, I played with your PR, and I did not have the need to make |
I want to introduce the interface because all symfony classes only need the getters. Having a lot of functions that are never used is a violation for Interface segration principle. I believe this is the argument for introducing the interface. A consequence of introducing the interface would be that we could allow the definition to be a service. The reason you want the definition as a service is because we want to use a Dumper. Currently there is no way to configure a definition in the config.yml and then dump it with Graphviz. |
Yes, it's possible. You can get the service workflow.xxx and then use the reflection on it. And IMHO, the definition should not be a service. it does nothing. It's just a data object that contain the configuration. It's OK for me to inline it inside a Workflow instance. |
Fair. As long as it is possible. So is this how we recommend people to dump the Definition? $workflow = $this->get('workflow.xxx');
$reflWorkflow = new ReflectionClass(workflow);
$reflProp = $reflWorkflow->getProperty('definition');
$reflProp->setAccessable(true);
$definition = $reflBaz->getValue(workflow);
$output = (new GraphvizDumper())->dump($definition); |
If they use the service, it means they are using the full stack framework, and so everything is already done in the command. If they don't use the full stack framework, it means they do everything by hand. so they have access to |
I see, I did not know of the Symfony command. Then there is no issue. Thank you. |
The reasoning behind ISP is not just "having a lot of functions that are never used", but ability to implement them independently in the first place. It's a very good sign of violation when you work with services, but data objects (entities, value objects) usually do not have different implementations, it's kinda weird to have 2 implementations of the However, I agree that mutability seems like flaw in the original design, because For me, it looks similar to the following issue: http://verraes.net/2016/02/type-safety-and-money/#parent-interface |
Unfortunately, PHP object are mutable ... |
If you don't add mutable methods, then it isn't. |
Hehe, indeed. But adding such feature will make the code harder to read. |
@lyrixx why so? I personally find easier to work with immutable objects as you don't have to watch for the side effects. There is obviously cases where you don't want immutability, but is there such a thing in the workflow component? |
@theofidry feel free to open a PR. |
is it ok to introduce BC breaks? |
If there is a real design issue, yes. But you have to be very quick because we already reached the feature freeze. After the release of 3.2, it will be too late. |
If it's worth it, I'll try to do it this week then :) |
Using psr7-like immutability? Let's see how it looks like !
|
Sure, or add a |
I really prefer the builder. |
I can give the builder a try.. Just a moment From: Grégoire Pineau notifications@github.com notifications@github.com I really prefer the builder. — |
I'd go with |
See #20451 |
This PR was squashed before being merged into the 3.2-dev branch (closes #20451). Discussion ---------- [Workflow] Added Definition builder | Q | A | ------------- | --- | Branch? | "master" | Bug fix? | no | New feature? | yes | BC breaks? | yes (in un-released branch) | Deprecations? | no | Tests pass? | yes | Fixed tickets | Related to #20441 | License | MIT | Doc PR | n/a Make the Definition immutable and add a DefinitionBuilder. I basically broke up the Definition class into an immutable class and one builder. Commits ------- ffaeba3 [Workflow] Added Definition builder
This PR adds an interface for the
Definition
. Following up on the discussions here: #19629 (comment)The Definition of a Workflow should not be changed after the workflow has been created. That means we should always consider the Definition as immutable after this point. By introducing this interface, we have the possibility create an
ImmutableDefinition
and make theworkflow.[name].definition
service public.Ping @lyrixx