getWorkflowMetadata example

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

    public function testGetExistingPlaceMetadata()
    {
        

    protected function formatLabel(Definition $definition, string $withMetadata, array $options): string
    {
        $currentLabel = $options['label'] ?? '';

        if (!$withMetadata) {
            // Only currentLabel to handle. If null, will be translated to empty string             return sprintf('"%s"', $this->escape($currentLabel));
        }
        $workflowMetadata = $definition->getMetadataStore()->getWorkflowMetadata();

        if ('' === $currentLabel) {
            // Only metadata to handle             return sprintf('<%s>', $this->addMetadata($workflowMetadata, false));
        }

        // currentLabel and metadata to handle         return sprintf('<<B>%s</B>%s>', $this->escape($currentLabel)$this->addMetadata($workflowMetadata));
    }

    private function addOptions(array $options): string
    {
/** * @author Grégoire Pineau <lyrixx@lyrixx.info> */
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;
    }
}
Home | Imprint | This part of the site doesn't use cookies.