[Workflow] Deprecated DefinitionBuilder::setInitialPlace()
Added missing part of #30468
This commit is contained in:
parent
a218efebee
commit
4d002e8397
|
@ -297,6 +297,8 @@ Workflow
|
|||
type: method
|
||||
```
|
||||
|
||||
* Using `DefinitionBuilder::setInitialPlace()` is deprecated, use `DefinitionBuilder::setInitialPlaces()` instead.
|
||||
|
||||
Yaml
|
||||
----
|
||||
|
||||
|
|
|
@ -385,11 +385,11 @@ TwigBundle
|
|||
* The default value (`false`) of the `twig.strict_variables` configuration option has been changed to `%kernel.debug%`.
|
||||
* The `transchoice` tag and filter have been removed, use the `trans` ones instead with a `%count%` parameter.
|
||||
* Removed support for legacy templates directories `src/Resources/views/` and `src/Resources/<BundleName>/views/`, use `templates/` and `templates/bundles/<BundleName>/` instead.
|
||||
|
||||
|
||||
TwigBridge
|
||||
----------
|
||||
|
||||
* removed the `$requestStack` and `$requestContext` arguments of the
|
||||
* removed the `$requestStack` and `$requestContext` arguments of the
|
||||
`HttpFoundationExtension`, pass a `Symfony\Component\HttpFoundation\UrlHelper`
|
||||
instance as the only argument instead
|
||||
|
||||
|
@ -417,6 +417,7 @@ Workflow
|
|||
* `MarkingStoreInterface::setMarking()` has a third argument: `array $context = []`.
|
||||
* Removed support of `initial_place`. Use `initial_places` instead.
|
||||
* `MultipleStateMarkingStore` has been removed. Use `MethodMarkingStore` instead.
|
||||
* `DefinitionBuilder::setInitialPlace()` has been removed, use `DefinitionBuilder::setInitialPlaces()` instead.
|
||||
|
||||
Before:
|
||||
```yaml
|
||||
|
|
|
@ -706,13 +706,10 @@ class FrameworkExtension extends Extension
|
|||
}
|
||||
|
||||
if ($validator) {
|
||||
$realDefinition = (new Workflow\DefinitionBuilder($places))
|
||||
->addTransitions(array_map(function (Reference $ref) use ($container): Workflow\Transition {
|
||||
return $container->get((string) $ref);
|
||||
}, $transitions))
|
||||
->setInitialPlace($initialMarking)
|
||||
->build()
|
||||
;
|
||||
$trs = array_map(function (Reference $ref) use ($container): Workflow\Transition {
|
||||
return $container->get((string) $ref);
|
||||
}, $transitions);
|
||||
$realDefinition = new Workflow\Definition($places, $trs, $initialMarking);
|
||||
$validator->validate($realDefinition, $name);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ CHANGELOG
|
|||
* Dispatch `CompletedEvent` on `workflow.completed`
|
||||
* Dispatch `AnnounceEvent` on `workflow.announce`
|
||||
* Added support for many `initialPlaces`
|
||||
* Deprecated `DefinitionBuilder::setInitialPlace()` method, use `DefinitionBuilder::setInitialPlaces()` instead.
|
||||
* Deprecated the `MultipleStateMarkingStore` class, use the `MethodMarkingStore` instead.
|
||||
* Deprecated the `SingleStateMarkingStore` class, use the `MethodMarkingStore` instead.
|
||||
|
||||
|
|
|
@ -48,13 +48,13 @@ final class Definition
|
|||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.3. Use the getInitialPlaces() instead.
|
||||
* @deprecated since Symfony 4.3. Use getInitialPlaces() instead.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getInitialPlace()
|
||||
{
|
||||
@trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated. Call %s::getInitialPlaces() instead.', __CLASS__, __CLASS__));
|
||||
@trigger_error(sprintf('Calling %s::getInitialPlace() is deprecated since Symfony 4.3. Call getInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
if (!$this->initialPlaces) {
|
||||
return null;
|
||||
|
|
|
@ -24,7 +24,7 @@ class DefinitionBuilder
|
|||
{
|
||||
private $places = [];
|
||||
private $transitions = [];
|
||||
private $initialPlace;
|
||||
private $initialPlaces;
|
||||
private $metadataStore;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ class DefinitionBuilder
|
|||
*/
|
||||
public function build()
|
||||
{
|
||||
return new Definition($this->places, $this->transitions, $this->initialPlace, $this->metadataStore);
|
||||
return new Definition($this->places, $this->transitions, $this->initialPlaces, $this->metadataStore);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,20 +54,36 @@ class DefinitionBuilder
|
|||
{
|
||||
$this->places = [];
|
||||
$this->transitions = [];
|
||||
$this->initialPlace = null;
|
||||
$this->initialPlaces = null;
|
||||
$this->metadataStore = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.3. Use setInitialPlaces() instead.
|
||||
*
|
||||
* @param string $place
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInitialPlace($place)
|
||||
{
|
||||
$this->initialPlace = $place;
|
||||
@trigger_error(sprintf('Calling %s::setInitialPlace() is deprecated since Symfony 4.3. Call setInitialPlaces() instead.', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
$this->initialPlaces = $place;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|string[]|null $initialPlaces
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInitialPlaces($initialPlaces)
|
||||
{
|
||||
$this->initialPlaces = $initialPlaces;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -80,7 +96,7 @@ class DefinitionBuilder
|
|||
public function addPlace($place)
|
||||
{
|
||||
if (!$this->places) {
|
||||
$this->initialPlace = $place;
|
||||
$this->initialPlaces = $place;
|
||||
}
|
||||
|
||||
$this->places[$place] = $place;
|
||||
|
|
|
@ -9,6 +9,7 @@ use Symfony\Component\Workflow\Transition;
|
|||
|
||||
class DefinitionBuilderTest extends TestCase
|
||||
{
|
||||
/** @group legacy */
|
||||
public function testSetInitialPlace()
|
||||
{
|
||||
$builder = new DefinitionBuilder(['a', 'b']);
|
||||
|
@ -18,6 +19,15 @@ class DefinitionBuilderTest extends TestCase
|
|||
$this->assertEquals(['b'], $definition->getInitialPlaces());
|
||||
}
|
||||
|
||||
public function testSetInitialPlaces()
|
||||
{
|
||||
$builder = new DefinitionBuilder(['a', 'b']);
|
||||
$builder->setInitialPlaces('b');
|
||||
$definition = $builder->build();
|
||||
|
||||
$this->assertEquals(['b'], $definition->getInitialPlaces());
|
||||
}
|
||||
|
||||
public function testAddTransition()
|
||||
{
|
||||
$places = range('a', 'b');
|
||||
|
|
Reference in New Issue