Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca566a5

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: [Workflow] Deprecated DefinitionBuilder::setInitialPlace()
2 parents 8dd5464 + 0d5258a commit ca566a5

File tree

7 files changed

+43
-16
lines changed

7 files changed

+43
-16
lines changed

UPGRADE-4.3.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ Workflow
297297
type: method
298298
```
299299

300+
* Using `DefinitionBuilder::setInitialPlace()` is deprecated, use `DefinitionBuilder::setInitialPlaces()` instead.
301+
300302
Yaml
301303
----
302304

UPGRADE-5.0.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,12 @@ TwigBundle
442442
* The default value (`false`) of the `twig.strict_variables` configuration option has been changed to `%kernel.debug%`.
443443
* The `transchoice` tag and filter have been removed, use the `trans` ones instead with a `%count%` parameter.
444444
* Removed support for legacy templates directories `src/Resources/views/` and `src/Resources/<BundleName>/views/`, use `templates/` and `templates/bundles/<BundleName>/` instead.
445-
445+
446446
TwigBridge
447447
----------
448448

449449
* Removed argument `$rootDir` from the `DebugCommand::__construct()` method and the 5th argument must be an instance of `FileLinkFormatter`
450-
* removed the `$requestStack` and `$requestContext` arguments of the
450+
* removed the `$requestStack` and `$requestContext` arguments of the
451451
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
452452
instance as the only argument instead
453453

@@ -476,6 +476,7 @@ Workflow
476476
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
477477
* Removed support of `initial_place`. Use `initial_places` instead.
478478
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
479+
* `DefinitionBuilder::setInitialPlace()` has been removed, use `DefinitionBuilder::setInitialPlaces()` instead.
479480

480481
Before:
481482
```yaml

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -707,13 +707,10 @@ private function registerWorkflowConfiguration(array $config, ContainerBuilder $
707707
}
708708

709709
if ($validator) {
710-
$realDefinition = (new Workflow\DefinitionBuilder($places))
711-
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
712-
return $container->get((string) $ref);
713-
}, $transitions))
714-
->setInitialPlace($initialMarking)
715-
->build()
716-
;
710+
$trs = array_map(function (Reference $ref) use ($container): Workflow\Transition {
711+
return $container->get((string) $ref);
712+
}, $transitions);
713+
$realDefinition = new Workflow\Definition($places, $trs, $initialMarking);
717714
$validator->validate($realDefinition, $name);
718715
}
719716

src/Symfony/Component/Workflow/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ CHANGELOG
2828
* Dispatch `CompletedEvent` on `workflow.completed`
2929
* Dispatch `AnnounceEvent` on `workflow.announce`
3030
* Added support for many `initialPlaces`
31+
* Deprecated `DefinitionBuilder::setInitialPlace()` method, use `DefinitionBuilder::setInitialPlaces()` instead.
3132
* Deprecated the `MultipleStateMarkingStore` class, use the `MethodMarkingStore` instead.
3233
* Deprecated the `SingleStateMarkingStore` class, use the `MethodMarkingStore` instead.
3334

src/Symfony/Component/Workflow/Definition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public function __construct(array $places, array $transitions, $initialPlaces =
4848
}
4949

5050
/**
51-
* @deprecated since Symfony 4.3. Use the getInitialPlaces() instead.
51+
* @deprecated since Symfony 4.3. Use getInitialPlaces() instead.
5252
*
5353
* @return string|null
5454
*/
5555
public function getInitialPlace()
5656
{
57-
@trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated. Call %s::getInitialPlaces() instead.', __CLASS__, __CLASS__));
57+
@trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated since Symfony 4.3. Call getInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED);
5858

5959
if (!$this->initialPlaces) {
6060
return null;

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DefinitionBuilder
2424
{
2525
private $places = [];
2626
private $transitions = [];
27-
private $initialPlace;
27+
private $initialPlaces;
2828
private $metadataStore;
2929

3030
/**
@@ -42,7 +42,7 @@ public function __construct(array $places = [], array $transitions = [])
4242
*/
4343
public function build()
4444
{
45-
return new Definition($this->places, $this->transitions, $this->initialPlace, $this->metadataStore);
45+
return new Definition($this->places, $this->transitions, $this->initialPlaces, $this->metadataStore);
4646
}
4747

4848
/**
@@ -54,20 +54,36 @@ public function clear()
5454
{
5555
$this->places = [];
5656
$this->transitions = [];
57-
$this->initialPlace = null;
57+
$this->initialPlaces = null;
5858
$this->metadataStore = null;
5959

6060
return $this;
6161
}
6262

6363
/**
64+
* @deprecated since Symfony 4.3. Use setInitialPlaces() instead.
65+
*
6466
* @param string $place
6567
*
6668
* @return $this
6769
*/
6870
public function setInitialPlace($place)
6971
{
70-
$this->initialPlace = $place;
72+
@trigger_error(sprintf('Calling %s::setInitialPlace() is deprecated since Symfony 4.3. Call setInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED);
73+
74+
$this->initialPlaces = $place;
75+
76+
return $this;
77+
}
78+
79+
/**
80+
* @param string|string[]|null $initialPlaces
81+
*
82+
* @return $this
83+
*/
84+
public function setInitialPlaces($initialPlaces)
85+
{
86+
$this->initialPlaces = $initialPlaces;
7187

7288
return $this;
7389
}
@@ -80,7 +96,7 @@ public function setInitialPlace($place)
8096
public function addPlace($place)
8197
{
8298
if (!$this->places) {
83-
$this->initialPlace = $place;
99+
$this->initialPlaces = $place;
84100
}
85101

86102
$this->places[$place] = $place;

src/Symfony/Component/Workflow/Tests/DefinitionBuilderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
class DefinitionBuilderTest extends TestCase
1111
{
12+
/** @group legacy */
1213
public function testSetInitialPlace()
1314
{
1415
$builder = new DefinitionBuilder(['a', 'b']);
@@ -18,6 +19,15 @@ public function testSetInitialPlace()
1819
$this->assertEquals(['b'], $definition->getInitialPlaces());
1920
}
2021

22+
public function testSetInitialPlaces()
23+
{
24+
$builder = new DefinitionBuilder(['a', 'b']);
25+
$builder->setInitialPlaces('b');
26+
$definition = $builder->build();
27+
28+
$this->assertEquals(['b'], $definition->getInitialPlaces());
29+
}
30+
2131
public function testAddTransition()
2232
{
2333
$places = range('a', 'b');

0 commit comments

Comments
 (0)