minor #27190 [Workflow] Added DefinitionBuilder::setMetadataStore(). (vudaltsov)
This PR was squashed before being merged into the 4.1 branch (closes #27190).
Discussion
----------
[Workflow] Added DefinitionBuilder::setMetadataStore().
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
This PR complements #26092.
Commits
-------
2882f8d8c8
[Workflow] Added DefinitionBuilder::setMetadataStore().
This commit is contained in:
commit
c54faf4111
@ -30,7 +30,6 @@ final class Definition
|
||||
/**
|
||||
* @param string[] $places
|
||||
* @param Transition[] $transitions
|
||||
* @param string|null $initialPlace
|
||||
*/
|
||||
public function __construct(array $places, array $transitions, string $initialPlace = null, MetadataStoreInterface $metadataStore = null)
|
||||
{
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\Workflow;
|
||||
|
||||
use Symfony\Component\Workflow\Metadata\MetadataStoreInterface;
|
||||
|
||||
/**
|
||||
* Builds a definition.
|
||||
*
|
||||
@ -23,6 +25,7 @@ class DefinitionBuilder
|
||||
private $places = array();
|
||||
private $transitions = array();
|
||||
private $initialPlace;
|
||||
private $metadataStore;
|
||||
|
||||
/**
|
||||
* @param string[] $places
|
||||
@ -39,7 +42,7 @@ class DefinitionBuilder
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return new Definition($this->places, $this->transitions, $this->initialPlace);
|
||||
return new Definition($this->places, $this->transitions, $this->initialPlace, $this->metadataStore);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,6 +55,7 @@ class DefinitionBuilder
|
||||
$this->places = array();
|
||||
$this->transitions = array();
|
||||
$this->initialPlace = null;
|
||||
$this->metadataStore = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -122,6 +126,16 @@ class DefinitionBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetadataStore(MetadataStoreInterface $metadataStore)
|
||||
{
|
||||
$this->metadataStore = $metadataStore;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 4.1, use the clear() method instead.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ namespace Symfony\Component\Workflow\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Workflow\DefinitionBuilder;
|
||||
use Symfony\Component\Workflow\Metadata\InMemoryMetadataStore;
|
||||
use Symfony\Component\Workflow\Transition;
|
||||
|
||||
class DefinitionBuilderTest extends TestCase
|
||||
@ -44,4 +45,14 @@ class DefinitionBuilderTest extends TestCase
|
||||
$this->assertEquals('a', $definition->getPlaces()['a']);
|
||||
$this->assertEquals('b', $definition->getPlaces()['b']);
|
||||
}
|
||||
|
||||
public function testSetMetadataStore()
|
||||
{
|
||||
$builder = new DefinitionBuilder(array('a'));
|
||||
$metadataStore = new InMemoryMetadataStore();
|
||||
$builder->setMetadataStore($metadataStore);
|
||||
$definition = $builder->build();
|
||||
|
||||
$this->assertSame($metadataStore, $definition->getMetadataStore());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user