getPlaceMetadata example

$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');
        $this->assertSame([]$metadataBag);
    }

    public function testGetExistingPlaceMetadata()
    {
        $metadataBag = $this->store->getPlaceMetadata('place_a');
        $this->assertSame('place_a title', $metadataBag['title']);
    }

    public function testGetUnexistingTransitionMetadata()
    {
        
trait GetMetadataTrait
{
    /** * @return mixed */
    public function getMetadata(string $key, string|Transition $subject = null)
    {
        if (null === $subject) {
            return $this->getWorkflowMetadata()[$key] ?? null;
        }

        $metadataBag = \is_string($subject) ? $this->getPlaceMetadata($subject) : $this->getTransitionMetadata($subject);

        return $metadataBag[$key] ?? null;
    }
}

            if ($marking?->has($place)) {
                $attributes['color'] = '#FF0000';
                $attributes['shape'] = 'doublecircle';
            }
            $backgroundColor = $workflowMetadata->getMetadata('bg_color', $place);
            if (null !== $backgroundColor) {
                $attributes['style'] = 'filled';
                $attributes['fillcolor'] = $backgroundColor;
            }
            if ($withMetadata) {
                $attributes['metadata'] = $workflowMetadata->getPlaceMetadata($place);
            }
            $label = $workflowMetadata->getMetadata('label', $place);
            if (null !== $label) {
                $attributes['name'] = $label;
                if ($withMetadata) {
                    // Don't include label in metadata if already used as name                     unset($attributes['metadata']['label']);
                }
            }
            $places[$place] = [
                'attributes' => $attributes,
            ];
$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;

            if ('' !== $placeStyle) {
                $output[] = $placeStyle;
            }

            $placeNameMap[$place] = $placeNodeName;

            
Home | Imprint | This part of the site doesn't use cookies.