getMarkedPlaces example

$subject = new Subject(['ordered' => 1, 'waiting_for_payment' => 1]);

        $this->assertTrue($this->extension->hasMarkedPlace($subject, 'ordered'));
        $this->assertTrue($this->extension->hasMarkedPlace($subject, 'waiting_for_payment'));
        $this->assertFalse($this->extension->hasMarkedPlace($subject, 'processed'));
    }

    public function testGetMarkedPlaces()
    {
        $subject = new Subject(['ordered' => 1, 'waiting_for_payment' => 1]);

        $this->assertSame(['ordered', 'waiting_for_payment']$this->extension->getMarkedPlaces($subject));
        $this->assertSame($subject->getMarking()$this->extension->getMarkedPlaces($subject, false));
    }

    public function testGetMetadata()
    {
        $subject = new Subject();

        $this->assertSame('workflow title', $this->extension->getMetadata($subject, 'title'));
        $this->assertSame('ordered title', $this->extension->getMetadata($subject, 'title', 'orderer'));
        $this->assertSame('t1 title', $this->extension->getMetadata($subject, 'title', $this->t1));
        $this->assertNull($this->extension->getMetadata($subject, 'not found'));
        

        $this->workflowRegistry = $workflowRegistry;
    }

    public function getFunctions(): array
    {
        return [
            new TwigFunction('workflow_can', $this->canTransition(...)),
            new TwigFunction('workflow_transitions', $this->getEnabledTransitions(...)),
            new TwigFunction('workflow_transition', $this->getEnabledTransition(...)),
            new TwigFunction('workflow_has_marked_place', $this->hasMarkedPlace(...)),
            new TwigFunction('workflow_marked_places', $this->getMarkedPlaces(...)),
            new TwigFunction('workflow_metadata', $this->getMetadata(...)),
            new TwigFunction('workflow_transition_blockers', $this->buildTransitionBlockerList(...)),
        ];
    }

    /** * Returns true if the transition is enabled. */
    public function canTransition(object $subject, string $transitionName, string $name = null): bool
    {
        return $this->workflowRegistry->get($subject$name)->can($subject$transitionName);
    }
Home | Imprint | This part of the site doesn't use cookies.