-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
There was a problem hiding this 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))); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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". |
There was a problem hiding this comment.
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
@lyrixx Ok, I committed all the changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add an entry in the CHANGELOG (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Workflow/CHANGELOG.md)
* | ||
* @return Workflow[] | ||
*/ | ||
public function all($subject): array |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about allBySubject()
then?
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the specific subject?
…kflows associated to a specific object #26618
Thank you @alexpozzi. |
…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
[Workflow][Registry] Added the 'all' method which returns all the workflows associated to a specific object #26618
As explained in 26628 I added the 'all' method which returns all the workflows associated to a specific object.