-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | no |
Symfony version | 3.4.x/4.x |
First of all thanks for the great work!
It would be great to have a method in the Registry class that returns all the workflows associated to a specific object class.
This would add the possibility to easily implement, for example, an admin UI where the admin can see the status of all the workflows associated to a specific object.
Would it be useful?
Is there a reason why it has not been implemented yet?
I would implement it this way:
class Registry
{
...
/**
* @param object $subject
*
* @return Workflow[]
*/
public function all($subject)
{
$matched = array();
foreach ($this->workflows as list($workflow, $supportStrategy)) {
if ($supportStrategy->supports($workflow, $subject)) {
$matched[] = $workflow;
}
}
if (empty($matched)) {
throw new InvalidArgumentException(sprintf('Unable to find any workflow for class "%s".', get_class($subject)));
}
return $matched;
}
...
}