Skip to content

Commit de66163

Browse files
author
Tobias Wojtylak
committed
Simplified DefaultStepController: Removed getter and default redirect in renderAction
1 parent 9d6ef6a commit de66163

File tree

2 files changed

+2
-60
lines changed

2 files changed

+2
-60
lines changed

src/Controller/DefaultStepController.php

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use solutionDrive\MultiStepBundle\Context\FlowContext;
1313
use solutionDrive\MultiStepBundle\Context\FlowContextInterface;
1414
use solutionDrive\MultiStepBundle\Exception\NoNextOrPreviousStepException;
15-
use solutionDrive\MultiStepBundle\Model\MultiStepFlowInterface;
1615
use solutionDrive\MultiStepBundle\Model\MultiStepInterface;
1716
use solutionDrive\MultiStepBundle\Router\MultistepRouterInterface;
1817
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -33,14 +32,6 @@ class DefaultStepController extends Controller implements TemplateAwareControlle
3332

3433
public function renderAction(Request $request): Response
3534
{
36-
// Enable simple navigation
37-
if ('next' === $request->get('navigate_to_direction')) {
38-
return $this->redirectToNextStep();
39-
} elseif ('previous' === $request->get('navigate_to_direction')) {
40-
return $this->redirectToPreviousStep();
41-
}
42-
43-
// Render template for current step
4435
return $this->render($this->getTemplate(), $this->getTemplateVariables());
4536
}
4637

@@ -53,12 +44,8 @@ public function renderAction(Request $request): Response
5344
public function getTemplateVariables(): array
5445
{
5546
return [
56-
'flow' => $this->getFlow(),
57-
'step' => $this->getStep(),
58-
'hasNextStep' => $this->hasNextStep(),
59-
'hasPreviousStep' => $this->hasPreviousStep(),
60-
'nextStepLink' => $this->getNextStepLink(),
61-
'previousStepLink' => $this->getPreviousStepLink(),
47+
'flow' => $this->flowContext->getFlow(),
48+
'step' => $this->flowContext->getCurrentStep(),
6249
];
6350
}
6451

@@ -88,22 +75,6 @@ protected function redirectToStep(MultiStepInterface $step, int $statusCode): Re
8875
return $this->redirect($this->router->generateStepLink($step), $statusCode);
8976
}
9077

91-
/**
92-
* Returns true if there is a next step in the flow.
93-
*/
94-
public function hasNextStep(): bool
95-
{
96-
return $this->flowContext->hasNextStep();
97-
}
98-
99-
/**
100-
* Returns true if there is a previous step in the flow.
101-
*/
102-
public function hasPreviousStep(): bool
103-
{
104-
return $this->flowContext->hasPreviousStep();
105-
}
106-
10778
/**
10879
* Returns the configured template.
10980
* Can be overriden in step definition, see README.md for details.
@@ -131,26 +102,6 @@ public function getPreviousStep(): ?MultiStepInterface
131102
return $this->flowContext->getPreviousStep();
132103
}
133104

134-
public function getNextStepLink(): ?string
135-
{
136-
return $this->hasNextStep() ? $this->router->generateStepLink($this->getNextStep()) : null;
137-
}
138-
139-
public function getPreviousStepLink(): ?string
140-
{
141-
return $this->hasPreviousStep() ? $this->router->generateStepLink($this->getPreviousStep()) : null;
142-
}
143-
144-
public function getFlow(): MultiStepFlowInterface
145-
{
146-
return $this->flowContext->getFlow();
147-
}
148-
149-
public function getStep(): ?MultiStepInterface
150-
{
151-
return $this->flowContext->getCurrentStep();
152-
}
153-
154105
public function getFlowContext(): FlowContextInterface
155106
{
156107
return $this->flowContext;

src/Controller/FlowAwareInterface.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace solutionDrive\MultiStepBundle\Controller;
1111

1212
use solutionDrive\MultiStepBundle\Context\FlowContextInterface;
13-
use solutionDrive\MultiStepBundle\Model\MultiStepFlowInterface;
1413
use solutionDrive\MultiStepBundle\Model\MultiStepInterface;
1514
use solutionDrive\MultiStepBundle\Router\MultistepRouterInterface;
1615

@@ -26,13 +25,5 @@ public function getRouter(): MultistepRouterInterface;
2625

2726
public function getNextStep(): ?MultiStepInterface;
2827

29-
public function getNextStepLink(): ?string;
30-
3128
public function getPreviousStep(): ?MultiStepInterface;
32-
33-
public function getPreviousStepLink(): ?string;
34-
35-
public function getStep(): ?MultiStepInterface;
36-
37-
public function getFlow(): MultiStepFlowInterface;
3829
}

0 commit comments

Comments
 (0)