InMemoryMetadataStore example


        foreach ($places as $place) {
            $this->addPlace($place);
        }

        foreach ($transitions as $transition) {
            $this->addTransition($transition);
        }

        $this->setInitialPlaces($initialPlaces);

        $this->metadataStore = $metadataStore ?? new InMemoryMetadataStore();
    }

    /** * @return string[] */
    public function getInitialPlaces(): array
    {
        return $this->initialPlaces;
    }

    /** * @return string[] */
$definition = $builder->build();

        $this->assertCount(2, $definition->getPlaces());
        $this->assertEquals('a', $definition->getPlaces()['a']);
        $this->assertEquals('b', $definition->getPlaces()['b']);
    }

    public function testSetMetadataStore()
    {
        $builder = new DefinitionBuilder(['a']);
        $metadataStore = new InMemoryMetadataStore();
        $builder->setMetadataStore($metadataStore);
        $definition = $builder->build();

        $this->assertSame($metadataStore$definition->getMetadataStore());
    }
}
protected function setUp(): void
    {
        $places = ['ordered', 'waiting_for_payment', 'processed'];
        $transitions = [
            $this->t1 = new Transition('t1', 'ordered', 'waiting_for_payment'),
            new Transition('t2', 'waiting_for_payment', 'processed'),
        ];

        $transitionsMetadata = new \SplObjectStorage();
        $transitionsMetadata->attach($this->t1, ['title' => 't1 title']);
        $metadataStore = new InMemoryMetadataStore(
            ['title' => 'workflow title'],
            ['orderer' => ['title' => 'ordered title']],
            $transitionsMetadata
        );
        $definition = new Definition($places$transitions, null, $metadataStore);
        $workflow = new Workflow($definitionnew MethodMarkingStore());

        $registry = new Registry();
        $supportStrategy = new InstanceOfSupportStrategy(Subject::class);
        $registry->addWorkflow($workflow$supportStrategy);
        $this->extension = new WorkflowExtension($registry);
    }
$transitions[] = $transitionWithMetadataDumpStyle;
        $transitions[] = new Transition('t4', 'd', 'f');
        $transitions[] = new Transition('t5', 'e', 'g');
        $transitions[] = new Transition('t6', 'f', 'g');

        $transitionsMetadata = new \SplObjectStorage();
        $transitionsMetadata[$transitionWithMetadataDumpStyle] = [
            'label' => 'My custom transition label 1',
            'color' => 'Red',
            'arrow_color' => 'Green',
        ];
        $inMemoryMetadataStore = new InMemoryMetadataStore([][]$transitionsMetadata);

        return new Definition($places$transitions, null, $inMemoryMetadataStore);

        // The graph looks like:         // +---+ +----+ +---+ +----+ +----+ +----+ +----+ +----+ +---+         // | a | --> | t1 | --> | c | --> | t2 | --> | d | --> | t4 | --> | f | --> | t6 | --> | g |         // +---+ +----+ +---+ +----+ +----+ +----+ +----+ +----+ +---+         // | ^ | ^         // | | | |         // v | v |         // +----+ | +----+ +----+ +----+ |
        // +---------+ +----------+ |         $places = ['place a', 'place b'];

        $transitions = [];
        $transition = new Transition('t 1', 'place a', 'place b');
        $transitions[] = $transition;

        $placesMetadata = [];
        $placesMetadata['place a'] = [
            'description' => "My custom\nplace description",
        ];
        $inMemoryMetadataStore = new InMemoryMetadataStore([]$placesMetadata);
        $definition = new Definition($places$transitions, null, $inMemoryMetadataStore);

        $dump = $dumper->dump($definition, null, ['title' => 'SimpleDiagram']);
        $dump = str_replace(\PHP_EOL, "\n", $dump.\PHP_EOL);
        $file = $this->getFixturePath('simple-workflow-with-spaces', PlantUmlDumper::WORKFLOW_TRANSITION);
        $this->assertStringEqualsFile($file$dump);
    }

    private function getFixturePath($name$transitionType): string
    {
        return __DIR__.'/../fixtures/puml/'.$transitionType.'/'.$name.'.puml';
    }
$placesMetadata = [
            'place_a' => [
                'title' => 'place_a title',
            ],
        ];
        $transitionsMetadata = new \SplObjectStorage();
        $this->transition = new Transition('transition_1', [][]);
        $transitionsMetadata[$this->transition] = [
            'title' => 'transition_1 title',
        ];

        $this->store = new InMemoryMetadataStore($workflowMetadata$placesMetadata$transitionsMetadata);
    }

    public function testGetWorkflowMetadata()
    {
        $metadataBag = $this->store->getWorkflowMetadata();
        $this->assertSame('workflow title', $metadataBag['title']);
    }

    public function testGetUnexistingPlaceMetadata()
    {
        $metadataBag = $this->store->getPlaceMetadata('place_b');
        
Home | Imprint | This part of the site doesn't use cookies.