Skip to content

Commit

Permalink
[Workflow] Fixed BC break with MarkingStoreInterface::setMarking()
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Mar 12, 2019
1 parent 18cd342 commit eeeb75d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
27 changes: 27 additions & 0 deletions UPGRADE-4.3.md
Expand Up @@ -110,3 +110,30 @@ Yaml
----

* Using a mapping inside a multi-line string is deprecated and will throw a `ParseException` in 5.0.

Workflow
--------

* `MarkingStoreInterface::setMarking()` will have a third argument in Symfony 5.0.

Before:
```php
class MyMarkingStore implements MarkingStoreInterface
{
public function setMarking($subject, Marking $marking)
{

}
}
```

After:
```php
class MyMarkingStore implements MarkingStoreInterface
{
public function setMarking($subject, Marking $marking , array $context = [])
{

}
}
```
3 changes: 2 additions & 1 deletion UPGRADE-5.0.md
Expand Up @@ -83,7 +83,7 @@ Finder

Form
----

* Removed support for using the `format` option of `DateType` and `DateTimeType` when the `html5` option is enabled.
* Using names for buttons that do not start with a letter, a digit, or an underscore leads to an exception.
* Using names for buttons that do not contain only letters, digits, underscores, hyphens, and colons leads to an
Expand Down Expand Up @@ -350,6 +350,7 @@ Workflow
* `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.
* `MarkingStoreInterface::setMarking()` have a third argument: `array $context = []`.

Yaml
----
Expand Down
Expand Up @@ -38,5 +38,5 @@ public function getMarking($subject);
*
* @param object $subject A subject
*/
public function setMarking($subject, Marking $marking, array $context = []);
public function setMarking($subject, Marking $marking /*, array $context = []*/);
}
6 changes: 6 additions & 0 deletions src/Symfony/Component/Workflow/Workflow.php
Expand Up @@ -37,6 +37,12 @@ public function __construct(Definition $definition, MarkingStoreInterface $marki
{
$this->definition = $definition;
$this->markingStore = $markingStore ?: new MultipleStateMarkingStore();

$r = new \ReflectionMethod($this->markingStore, 'setMarking');
if (3 > \count($r->getParameters())) {
@trigger_error(sprintf('The MarkingStore "%s" should have a third arguments "array $context = []".', get_class($this->markingStore)), E_USER_DEPRECATED);
}

$this->dispatcher = $dispatcher;
$this->name = $name;
}
Expand Down

0 comments on commit eeeb75d

Please sign in to comment.