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

Skip to content

[Workflow][Registry] Added a new 'all' method #26656

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 2 commits into from
Apr 2, 2018
Merged

[Workflow][Registry] Added a new 'all' method #26656

merged 2 commits into from
Apr 2, 2018

Conversation

alexpozzi
Copy link
Contributor

@alexpozzi alexpozzi commented Mar 23, 2018

[Workflow][Registry] Added the 'all' method which returns all the workflows associated to a specific object #26618

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

As explained in 26628 I added the 'all' method which returns all the workflows associated to a specific object.

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.

Hello.

First thanks for your first contribution on Symfony 🎉

Then, It's almost perfect. I just let few minor comments

}
}
if (empty($matched)) {
throw new InvalidArgumentException(sprintf('Unable to find any workflow for class "%s".', get_class($subject)));
Copy link
Member

Choose a reason for hiding this comment

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

I would not throw an exception here. Just return the empty array

*
* @return Workflow[]
*/
public function all($subject)
Copy link
Member

Choose a reason for hiding this comment

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

Could you add the return type hint: : array

{
$workflows = $this->registry->all(new Subject1());
$this->assertInternalType('array', $workflows);
$this->assertEquals(1, count($workflows));
Copy link
Member

Choose a reason for hiding this comment

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

you can use $this->assertCount(1, $workflows);


/**
* @expectedException \Symfony\Component\Workflow\Exception\InvalidArgumentException
* @expectedExceptionMessage Unable to find any workflow for class "stdClass".
Copy link
Member

Choose a reason for hiding this comment

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

So you should remove theses expectation

@alexpozzi
Copy link
Contributor Author

@lyrixx Ok, I committed all the changes.

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.

*
* @return Workflow[]
*/
public function all($subject): array
Copy link
Member

Choose a reason for hiding this comment

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

Actually I'm not really sure about this name. You don't return all Workflows, but only workflows for a specific subject.
Maybe filterBySubject is a better name? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose all because the other function is called get (and not getBySubject).
BTW I think that filterBySubject is fine as well and it better explains what the function does.

Let me know if I have to change the name of the function, so I'll submit it together with the updated CHANGELOG.md file.

Copy link
Member

Choose a reason for hiding this comment

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

You are right about the get. Let's keep all.

Copy link
Member

Choose a reason for hiding this comment

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

What about allBySubject() then?

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.

👍 with the CHANGELOG

*
* @return Workflow[]
*/
public function all($subject): array
Copy link
Member

Choose a reason for hiding this comment

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

You are right about the get. Let's keep all.

@@ -11,6 +11,7 @@ CHANGELOG
* Added TransitionBlockers as a way to pass around reasons why exactly
transitions can't be made.
* Added a `MetadataStore`.
* Added the method `all` which returns all the workflows associated to the specified subject
Copy link
Member

@lyrixx lyrixx Mar 26, 2018

Choose a reason for hiding this comment

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

Added Registry::all to returns all [...] subject.

@@ -11,6 +11,7 @@ CHANGELOG
* Added TransitionBlockers as a way to pass around reasons why exactly
transitions can't be made.
* Added a `MetadataStore`.
* Added Registry::all to return all the workflows associated to the specified subject
Copy link
Member

@fabpot fabpot Mar 27, 2018

Choose a reason for hiding this comment

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

with the specific subject?

@lyrixx
Copy link
Member

lyrixx commented Apr 2, 2018

Thank you @alexpozzi.

@lyrixx lyrixx merged commit ca1352d into symfony:master Apr 2, 2018
lyrixx added a commit that referenced this pull request Apr 2, 2018
…zi, lyrixx)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[Workflow][Registry] Added a new 'all' method

[Workflow][Registry] Added the 'all' method which returns all the workflows associated to a specific object #26618

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

As explained in [26628](#26618 (comment))  I added the 'all' method which returns all the workflows associated to a specific object.

Commits
-------

ca1352d Fixed CHANGELOG
baec431 [Workflow][Registry] Added the 'all' method which returns all the workflows associated to a specific object #26618
@fabpot fabpot mentioned this pull request May 7, 2018
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.

7 participants