feature #27092 [Workflow] "clear()" instead of "reset()" (nicolas-grekas)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Workflow] "clear()" instead of "reset()"
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
While working on another PR (to come), I noticed that the workflow component is using the word "reset" for something that is consistently called "clear" in the rest of the code base (emptying the state of an object) - and also that "reset" is consistently used for setting an object back to its initial state (which might not be the empty state, contrary to what clear does).
Here is a PR fixing this inconsistency. Should be on 4.1 so that we won't have to deal with another BC layer in 4.2.
Commits
-------
858fabb10b
[Workflow] "clear()" instead of "reset()"
This commit is contained in:
commit
5a5b925f54
@ -154,6 +154,7 @@ Validator
|
|||||||
Workflow
|
Workflow
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
* Deprecated the `DefinitionBuilder::reset()` method, use the `clear()` one instead.
|
||||||
* Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry`.
|
* Deprecated the `add` method in favor of the `addWorkflow` method in `Workflow\Registry`.
|
||||||
* Deprecated `SupportStrategyInterface` in favor of `WorkflowSupportStrategyInterface`.
|
* Deprecated `SupportStrategyInterface` in favor of `WorkflowSupportStrategyInterface`.
|
||||||
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
|
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
|
||||||
|
@ -107,6 +107,7 @@ Validator
|
|||||||
Workflow
|
Workflow
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
* The `DefinitionBuilder::reset()` method has been removed, use the `clear()` one instead.
|
||||||
* `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead.
|
* `add` method has been removed use `addWorkflow` method in `Workflow\Registry` instead.
|
||||||
* `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead.
|
* `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead.
|
||||||
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
|
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
|
||||||
|
@ -4,8 +4,9 @@ CHANGELOG
|
|||||||
4.1.0
|
4.1.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* Deprecate the usage of `add(Workflow $workflow, $supportStrategy)` in `Workflow/Registry`, use `addWorkflow(WorkflowInterface, $supportStrategy)` instead.
|
* Deprecated the `DefinitionBuilder::reset()` method, use the `clear()` one instead.
|
||||||
* Deprecate the usage of `SupportStrategyInterface`, use `WorkflowSupportStrategyInterface` instead.
|
* Deprecated the usage of `add(Workflow $workflow, $supportStrategy)` in `Workflow/Registry`, use `addWorkflow(WorkflowInterface, $supportStrategy)` instead.
|
||||||
|
* Deprecated the usage of `SupportStrategyInterface`, use `WorkflowSupportStrategyInterface` instead.
|
||||||
* The `Workflow` class now implements `WorkflowInterface`.
|
* The `Workflow` class now implements `WorkflowInterface`.
|
||||||
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
|
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
|
||||||
* Added TransitionBlockers as a way to pass around reasons why exactly
|
* Added TransitionBlockers as a way to pass around reasons why exactly
|
||||||
|
@ -47,7 +47,7 @@ class DefinitionBuilder
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function reset()
|
public function clear()
|
||||||
{
|
{
|
||||||
$this->places = array();
|
$this->places = array();
|
||||||
$this->transitions = array();
|
$this->transitions = array();
|
||||||
@ -121,4 +121,16 @@ class DefinitionBuilder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since Symfony 4.1, use the clear() method instead.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function reset()
|
||||||
|
{
|
||||||
|
@trigger_error(sprintf('The "%s" method is deprecated since Symfony 4.1, use the "clear()" method instead.', __METHOD__), E_USER_DEPRECATED);
|
||||||
|
|
||||||
|
return $this->clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class GuardEvent extends Event
|
|||||||
public function setBlocked($blocked)
|
public function setBlocked($blocked)
|
||||||
{
|
{
|
||||||
if (!$blocked) {
|
if (!$blocked) {
|
||||||
$this->transitionBlockerList->reset();
|
$this->transitionBlockerList->clear();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ final class TransitionBlockerList implements \IteratorAggregate, \Countable
|
|||||||
$this->blockers[] = $blocker;
|
$this->blockers[] = $blocker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset(): void
|
public function clear(): void
|
||||||
{
|
{
|
||||||
$this->blockers = array();
|
$this->blockers = array();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user