8000 Added DefinitionBuilder::setMetadataStore(). · symfony/symfony@04d528b · GitHub
[go: up one dir, main page]

Skip to content

Commit 04d528b

Browse files
committed
Added DefinitionBuilder::setMetadataStore().
1 parent ce5c47c commit 04d528b

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

src/Symfony/Component/Workflow/Definition.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ final class Definition
2828
private $metadataStore;
2929

3030
/**
31-
* @param string[] $places
32-
* @param Transition[] $transitions
33-
* @param string|null $initialPlace
31+
* @param string[] $places
32+
* @param Transition[] $transitions
33+
* @param string|null $initialPlace
34+
* @param MetadataStoreInterface|null $metadataStore
3435
*/
3536
public function __construct(array $places, array $transitions, string $initialPlace = null, MetadataStoreInterface $metadataStore = null)
3637
{

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 19 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
}
@@ -113,6 +117,8 @@ public function addTransitions(array $transitions)
113117
}
114118

115119
/**
120+
* @param Transition $transition
121+
*
116122
* @return $this
117123
*/
118124
public function addTransition(Transition $transition)
@@ -122,6 +128,18 @@ public function addTransition(Transition $transition)
122128
return $this;
123129
}
124130

131+
/**
132+
* @param MetadataStoreInterface $metadataStore
133+
*
134+
* @return $this
135+
*/
136+
public function setMetadataStore(MetadataStoreInterface $metadataStore)
137+
{
138+
$this->metadataStore = $metadataStore;
139+
140+
return $this;
141+
}
142+
125143
/**
126144
* @deprecated since Symfony 4.1, use the clear() method instead.
127145
*

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)
0