Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

WorkflowExtension.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 3.02 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Bridge\Twig\Extension;
 013   
 014  use Symfony\Component\Workflow\Registry;
 015  use Symfony\Component\Workflow\Transition;
 016  use Twig\Extension\AbstractExtension;
 017  use Twig\TwigFunction;
 018   
 019  /**
 020   * WorkflowExtension.
 021   *
 022   * @author Grégoire Pineau <lyrixx@lyrixx.info>
 023   */
 024  class WorkflowExtension extends AbstractExtension
 025  {
 026      private $workflowRegistry;
 027   
 028      public function __construct(Registry $workflowRegistry)
 029      {
 030          $this->workflowRegistry = $workflowRegistry;
 031      }
 032   
 033      public function getFunctions()
 034      {
 035          return [
 036              new TwigFunction('workflow_can', [$this, 'canTransition']),
 037              new TwigFunction('workflow_transitions', [$this, 'getEnabledTransitions']),
 038              new TwigFunction('workflow_has_marked_place', [$this, 'hasMarkedPlace']),
 039              new TwigFunction('workflow_marked_places', [$this, 'getMarkedPlaces']),
 040          ];
 041      }
 042   
 043      /**
 044       * Returns true if the transition is enabled.
 045       *
 046       * @param object $subject        A subject
 047       * @param string $transitionName A transition
 048       * @param string $name           A workflow name
 049       *
 050       * @return bool true if the transition is enabled
 051       */
 052      public function canTransition($subject, $transitionName, $name = null)
 053      {
 054          return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName);
 055      }
 056   
 057      /**
 058       * Returns all enabled transitions.
 059       *
 060       * @param object $subject A subject
 061       * @param string $name    A workflow name
 062       *
 063       * @return Transition[] All enabled transitions
 064       */
 065      public function getEnabledTransitions($subject, $name = null)
 066      {
 067          return $this->workflowRegistry->get($subject, $name)->getEnabledTransitions($subject);
 068      }
 069   
 070      /**
 071       * Returns true if the place is marked.
 072       *
 073       * @param object $subject   A subject
 074       * @param string $placeName A place name
 075       * @param string $name      A workflow name
 076       *
 077       * @return bool true if the transition is enabled
 078       */
 079      public function hasMarkedPlace($subject, $placeName, $name = null)
 080      {
 081          return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName);
 082      }
 083   
 084      /**
 085       * Returns marked places.
 086       *
 087       * @param object $subject        A subject
 088       * @param bool   $placesNameOnly If true, returns only places name. If false returns the raw representation
 089       * @param string $name           A workflow name
 090       *
 091       * @return string[]|int[]
 092       */
 093      public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null)
 094      {
 095          $places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces();
 096   
 097          if ($placesNameOnly) {
 098              return array_keys($places);
 099          }
 100   
 101          return $places;
 102      }
 103   
 104      public function getName()
 105      {
 106          return 'workflow';
 107      }
 108  }
 109