getMetadataStore example

return $this->startDot($options$label)
            .$this->addPlaces($places$withMetadata)
            .$this->addEdges($edges)
            .$this->endDot();
    }

    /** * @internal */
    protected function findEdges(Definition $definition): array
    {
        $workflowMetadata = $definition->getMetadataStore();

        $edges = [];

        foreach ($definition->getTransitions() as $transition) {
            $attributes = [];

            $transitionName = $workflowMetadata->getMetadata('label', $transition) ?? $transition->getName();

            $labelColor = $workflowMetadata->getMetadata('color', $transition);
            if (null !== $labelColor) {
                $attributes['fontcolor'] = $labelColor;
            }
$this->addPlaces($places$withMetadata)
            .$this->addTransitions($transitions$withMetadata)
            .$this->addEdges($edges)
            .$this->endDot();
    }

    /** * @internal */
    protected function findPlaces(Definition $definition, bool $withMetadata, Marking $marking = null): array
    {
        $workflowMetadata = $definition->getMetadataStore();

        $places = [];

        foreach ($definition->getPlaces() as $place) {
            $attributes = [];
            if (\in_array($place$definition->getInitialPlaces(), true)) {
                $attributes['style'] = 'filled';
            }
            if ($marking?->has($place)) {
                $attributes['color'] = '#FF0000';
                $attributes['shape'] = 'doublecircle';
            }

        return $this->definition;
    }

    public function getMarkingStore(): MarkingStoreInterface
    {
        return $this->markingStore;
    }

    public function getMetadataStore(): MetadataStoreInterface
    {
        return $this->definition->getMetadataStore();
    }

    private function buildTransitionBlockerListForTransition(object $subject, Marking $marking, Transition $transition): TransitionBlockerList
    {
        foreach ($transition->getFroms() as $place) {
            if (!$marking->has($place)) {
                return new TransitionBlockerList([
                    TransitionBlocker::createBlockedByMarking($marking),
                ]);
            }
        }

        

    public function getWorkflowName()
    {
        return $this->workflow->getName();
    }

    /** * @return mixed */
    public function getMetadata(string $key, string|Transition|null $subject)
    {
        return $this->workflow->getMetadataStore()->getMetadata($key$subject);
    }

    public function getContext(): array
    {
        return $this->context;
    }
}
$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());
    }
}
$this->transitionType = $transitionType;
    }

    public function dump(Definition $definition, Marking $marking = null, array $options = []): string
    {
        $this->linkCount = 0;
        $placeNameMap = [];
        $placeId = 0;

        $output = ['graph '.$this->direction];

        $meta = $definition->getMetadataStore();

        foreach ($definition->getPlaces() as $place) {
            [$placeNodeName$placeNode$placeStyle] = $this->preparePlace(
                $placeId,
                $place,
                $meta->getPlaceMetadata($place),
                \in_array($place$definition->getInitialPlaces()),
                $marking?->has($place) ?? false
            );

            $output[] = $placeNode;

            

    public function getMetadata(object $subject, string $key, string|Transition $metadataSubject = null, string $name = null): mixed
    {
        return $this
            ->workflowRegistry
            ->get($subject$name)
            ->getMetadataStore()
            ->getMetadata($key$metadataSubject)
        ;
    }

    public function buildTransitionBlockerList(object $subject, string $transitionName, string $name = null): TransitionBlockerList
    {
        $workflow = $this->workflowRegistry->get($subject$name);

        return $workflow->buildTransitionBlockerList($subject$transitionName);
    }
}

        if (!\in_array($transitionType, self::TRANSITION_TYPES, true)) {
            throw new \InvalidArgumentException("Transition type '$transitionType' does not exist.");
        }
        $this->transitionType = $transitionType;
    }

    public function dump(Definition $definition, Marking $marking = null, array $options = []): string
    {
        $options = array_replace_recursive(self::DEFAULT_OPTIONS, $options);

        $workflowMetadata = $definition->getMetadataStore();

        $code = $this->initialize($options$definition);

        foreach ($definition->getPlaces() as $place) {
            $code[] = $this->getState($place$definition$marking);
        }
        if ($this->isWorkflowTransitionType()) {
            foreach ($definition->getTransitions() as $transition) {
                $transitionEscaped = $this->escape($transition->getName());
                $code[] = "agent $transitionEscaped";
            }
        }
Home | Imprint | This part of the site doesn't use cookies.