migration symfony 5 4 (#300)

* symfony 5.4 (diff dev)

* symfony 5.4 (working)

* symfony 5.4 (update autoload)

* symfony 5.4 (remove swiftmailer mailer implementation)

* symfony 5.4 (php doc and split Global accessor class)


### Impacted packages:

composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies

composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
bdalsass
2022-06-16 09:13:24 +02:00
committed by GitHub
parent abb13b70b9
commit 79da71ecf8
2178 changed files with 87439 additions and 59451 deletions

View File

@@ -13,6 +13,7 @@ namespace Symfony\Bridge\Twig\Extension;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\TransitionBlockerList;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
@@ -20,8 +21,9 @@ use Twig\TwigFunction;
* WorkflowExtension.
*
* @author Grégoire Pineau <lyrixx@lyrixx.info>
* @author Carlos Pereira De Amorim <carlos@shauri.fr>
*/
class WorkflowExtension extends AbstractExtension
final class WorkflowExtension extends AbstractExtension
{
private $workflowRegistry;
@@ -30,26 +32,26 @@ class WorkflowExtension extends AbstractExtension
$this->workflowRegistry = $workflowRegistry;
}
public function getFunctions()
/**
* {@inheritdoc}
*/
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.
*
* @param object $subject A subject
* @param string $transitionName A transition
* @param string $name A workflow name
*
* @return bool true if the transition is enabled
*/
public function canTransition($subject, $transitionName, $name = null)
public function canTransition(object $subject, string $transitionName, string $name = null): bool
{
return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName);
}
@@ -57,26 +59,22 @@ class WorkflowExtension extends AbstractExtension
/**
* Returns all enabled transitions.
*
* @param object $subject A subject
* @param string $name A workflow name
*
* @return Transition[] All enabled transitions
* @return Transition[]
*/
public function getEnabledTransitions($subject, $name = null)
public function getEnabledTransitions(object $subject, string $name = null): array
{
return $this->workflowRegistry->get($subject, $name)->getEnabledTransitions($subject);
}
public function getEnabledTransition(object $subject, string $transition, string $name = null): ?Transition
{
return $this->workflowRegistry->get($subject, $name)->getEnabledTransition($subject, $transition);
}
/**
* Returns true if the place is marked.
*
* @param object $subject A subject
* @param string $placeName A place name
* @param string $name A workflow name
*
* @return bool true if the transition is enabled
*/
public function hasMarkedPlace($subject, $placeName, $name = null)
public function hasMarkedPlace(object $subject, string $placeName, string $name = null): bool
{
return $this->workflowRegistry->get($subject, $name)->getMarking($subject)->has($placeName);
}
@@ -84,13 +82,9 @@ class WorkflowExtension extends AbstractExtension
/**
* Returns marked places.
*
* @param object $subject A subject
* @param bool $placesNameOnly If true, returns only places name. If false returns the raw representation
* @param string $name A workflow name
*
* @return string[]|int[]
*/
public function getMarkedPlaces($subject, $placesNameOnly = true, $name = null)
public function getMarkedPlaces(object $subject, bool $placesNameOnly = true, string $name = null): array
{
$places = $this->workflowRegistry->get($subject, $name)->getMarking($subject)->getPlaces();
@@ -101,8 +95,27 @@ class WorkflowExtension extends AbstractExtension
return $places;
}
public function getName()
/**
* Returns the metadata for a specific subject.
*
* @param string|Transition|null $metadataSubject Use null to get workflow metadata
* Use a string (the place name) to get place metadata
* Use a Transition instance to get transition metadata
*/
public function getMetadata(object $subject, string $key, $metadataSubject = null, string $name = null)
{
return 'workflow';
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);
}
}