Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Workflow] Fixed graphviz dumper for state machine #20583

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

Merged
merged 1 commit into from
Nov 24, 2016

Conversation

lyrixx
Copy link
Member

@lyrixx lyrixx commented Nov 21, 2016

Q A
Branch? master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #20497
License MIT
Doc PR ~

Before:
before
After:
after


Script:

<?php

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\StateMachine;
use Symfony\Component\Workflow\Transition;

$places = array('a', 'b', 'c', 'd');
$transitions[] = new Transition('t1', 'a', 'b');
$transitions[] = new Transition('t1', 'd', 'b');
$transitions[] = new Transition('t2', 'b', 'c');
$transitions[] = new Transition('t3', 'b', 'd');
$definition = new Definition($places, $transitions);

$marking = new Marking(['d' => 1]);

echo (new StateMachineGraphvizDumper())->dump($definition, $marking);

} elseif ($container->has('state_machine.'.$serviceId)) {
$workflow = $container->get('state_machine.'.$serviceId);
$dumper = new StateMachineGraphvizDumper();
Copy link
Member

Choose a reason for hiding this comment

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

should we have a way to dump the state machine in workflow mode ? It is a subset after all.

But anyway, I agree it should not be the default dumping for state machines.

Copy link
Member

Choose a reason for hiding this comment

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

this of course means that it should be fixed to work properly, but I know how to do this (stop assuming that transition names are unique identifiers of the transition, as we stopped doing this.

Copy link
Member Author

Choose a reason for hiding this comment

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

should we have a way to dump the state machine in workflow mode ?

For now, it's not really readable to dump a state machine with the workflow dumper. So IMHO, it's not useful to add a way to do it.

}

return $code;
}

private function findEdges(Definition $definition)
protected function findEdges(Definition $definition)
Copy link
Member

Choose a reason for hiding this comment

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

IMO, this should not be protected extension points. This seems like the wrong way to reuse part of the GraphvizDumper (fixing the dumping of transitions to stop assuming unique names might require refactoring private methods, but making them protected forbids this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really understand what you mean. Could you elaborate?

Copy link
Member Author

Choose a reason for hiding this comment

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

If you are talking about composition, it's not really possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added @internal everywhere.

@lyrixx lyrixx force-pushed the workflow-dump-state-machine branch from 41568ac to cc949bb Compare November 24, 2016 18:07
@lyrixx lyrixx force-pushed the workflow-dump-state-machine branch from cc949bb to 1e92e02 Compare November 24, 2016 18:07
@lyrixx lyrixx added this to the 3.2 milestone Nov 24, 2016
@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

fabpot commented Nov 24, 2016

Thank you @lyrixx.

@fabpot fabpot merged commit 1e92e02 into symfony:master Nov 24, 2016
fabpot added a commit that referenced this pull request Nov 24, 2016
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Workflow] Fixed graphviz dumper for state machine

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20497
| License       | MIT
| Doc PR        | ~

---

Before:
![before](https://cloud.githubusercontent.com/assets/408368/20490801/77cc0abe-b00f-11e6-8094-f4d428d5acde.png)
After:
![after](https://cloud.githubusercontent.com/assets/408368/20490809/7d21a4b0-b00f-11e6-8de2-c5021fe2d4e0.png)

---

Script:
```php
<?php

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\StateMachine;
use Symfony\Component\Workflow\Transition;

$places = array('a', 'b', 'c', 'd');
$transitions[] = new Transition('t1', 'a', 'b');
$transitions[] = new Transition('t1', 'd', 'b');
$transitions[] = new Transition('t2', 'b', 'c');
$transitions[] = new Transition('t3', 'b', 'd');
$definition = new Definition($places, $transitions);

$marking = new Marking(['d' => 1]);

echo (new StateMachineGraphvizDumper())->dump($definition, $marking);
```

Commits
-------

1e92e02 [Workflow] Fixed graphviz dumper for state machine
@chalasr
Copy link
Member

chalasr commented Nov 24, 2016

Unless I missed something, this should have been merged in 3.2 instead

@fabpot
Copy link
Member

fabpot commented Nov 24, 2016

Indeed, thanks for noticing.

@lyrixx lyrixx deleted the workflow-dump-state-machine branch November 24, 2016 21:21
fabpot added a commit that referenced this pull request Nov 24, 2016
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #20583).

Discussion
----------

[Workflow] Fixed graphviz dumper for state machine

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #20497
| License       | MIT
| Doc PR        | ~

---

Before:
![before](https://cloud.githubusercontent.com/assets/408368/20490801/77cc0abe-b00f-11e6-8094-f4d428d5acde.png)
After:
![after](https://cloud.githubusercontent.com/assets/408368/20490809/7d21a4b0-b00f-11e6-8de2-c5021fe2d4e0.png)

---

Script:
```php
<?php

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Dumper\StateMachineGraphvizDumper;
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\StateMachine;
use Symfony\Component\Workflow\Transition;

$places = array('a', 'b', 'c', 'd');
$transitions[] = new Transition('t1', 'a', 'b');
$transitions[] = new Transition('t1', 'd', 'b');
$transitions[] = new Transition('t2', 'b', 'c');
$transitions[] = new Transition('t3', 'b', 'd');
$definition = new Definition($places, $transitions);

$marking = new Marking(['d' => 1]);

echo (new StateMachineGraphvizDumper())->dump($definition, $marking);
```

Commits
-------

330c069 [Workflow] Fixed graphviz dumper for state machine
@fabpot fabpot mentioned this pull request Nov 27, 2016
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.

6 participants