Skip to content

[Workflow] "clear()" instead of "reset()" #27092

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
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADE-4.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ Validator
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 `SupportStrategyInterface` in favor of `WorkflowSupportStrategyInterface`.
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Validator
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.
* `SupportStrategyInterface` has been removed, use `WorkflowSupportStrategyInterface` instead.
* `ClassInstanceSupportStrategy` has been removed, use `InstanceOfSupportStrategy` instead.
5 changes: 3 additions & 2 deletions src/Symfony/Component/Workflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ CHANGELOG
4.1.0
-----

* Deprecate the usage of `add(Workflow $workflow, $supportStrategy)` in `Workflow/Registry`, use `addWorkflow(WorkflowInterface, $supportStrategy)` instead.
* Deprecate the usage of `SupportStrategyInterface`, use `WorkflowSupportStrategyInterface` instead.
* Deprecated the `DefinitionBuilder::reset()` method, use the `clear()` one 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`.
* Deprecated the class `ClassInstanceSupportStrategy` in favor of the class `InstanceOfSupportStrategy`.
* Added TransitionBlockers as a way to pass around reasons why exactly
Expand Down
14 changes: 13 additions & 1 deletion src/Symfony/Component/Workflow/DefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function build()
*
* @return $this
*/
public function reset()
public function clear()
{
$this->places = array();
$this->transitions = array();
Expand Down Expand Up @@ -121,4 +121,16 @@ public function addTransition(Transition $transition)

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();
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/Event/GuardEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function isBlocked()
public function setBlocked($blocked)
{
if (!$blocked) {
$this->transitionBlockerList->reset();
$this->transitionBlockerList->clear();

return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Workflow/TransitionBlockerList.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function add(TransitionBlocker $blocker): void
$this->blockers[] = $blocker;
}

public function reset(): void
public function clear(): void
{
$this->blockers = array();
}
Expand Down