Skip to content

Commit 2882f8d

Browse files
vudaltsovfabpot
authored andcommitted
[Workflow] Added DefinitionBuilder::setMetadataStore().
1 parent c3d4536 commit 2882f8d

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/Symfony/Component/Workflow/Definition.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ final class Definition
3030
/**
3131
* @param string[] $places
3232
* @param Transition[] $transitions
33-
* @param string|null $initialPlace
3433
*/
3534
public function __construct(array $places, array $transitions, string $initialPlace = null, MetadataStoreInterface $metadataStore = null)
3635
{

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Workflow;
1313

14+
use Symfony\Component\Workflow\Metadata\MetadataStoreInterface;
15+
1416
/**
1517
* Builds a definition.
1618
*
@@ -23,6 +25,7 @@ class DefinitionBuilder
2325
private $places = array();
2426
private $transitions = array();
2527
private $initialPlace;
28+
private $metadataStore;
2629

2730
/**
2831
* @param string[] $places
@@ -39,7 +42,7 @@ public function __construct(array $places = array(), array $transitions = array(
3942
*/
4043
public function build()
4144
{
42-
return new Definition($this->places, $this->transitions, $this->initialPlace);
45+
return new Definition($this->places, $this->transitions, $this->initialPlace, $this->metadataStore);
4346
}
4447

4548
/**
@@ -52,6 +55,7 @@ public function clear()
5255
$this->places = array();
5356
$this->transitions = array();
5457
$this->initialPlace = null;
58+
$this->metadataStore = null;
5559

5660
return $this;
5761
}
@@ -122,6 +126,16 @@ public function addTransition(Transition $transition)
122126
return $this;
123127
}
124128

129+
/**
130+
* @return $this
131+
*/
132+
public function setMetadataStore(MetadataStoreInterface $metadataStore)
133+
{
134+
$this->metadataStore = $metadataStore;
135+
136+
return $this;
137+
}
138+
125139
/**
126140
* @deprecated since Symfony 4.1, use the clear() method instead.
127141
*

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHPUnit\Framework\TestCase;
66
use Symfony\Component\Workflow\DefinitionBuilder;
7+
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
78
use Symfony\Component\Workflow\Transition;
89

910
class DefinitionBuilderTest extends TestCase
@@ -44,4 +45,14 @@ public function testAddPlace()
4445
$this->assertEquals('a', $definition->getPlaces()['a']);
4546
$this->assertEquals('b', $definition->getPlaces()['b']);
4647
}
48+
49+
public function testSetMetadataStore()
50+
{
51+
$builder = new DefinitionBuilder(array('a'));
52+
$metadataStore = new InMemoryMetadataStore();
53+
$builder->setMetadataStore($metadataStore);
54+
$definition = $builder->build();
55+
56+
$this->assertSame($metadataStore, $definition->getMetadataStore());
57+
}
4758
}

0 commit comments

Comments
 (0)