-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathFormFlowUtil.php
More file actions
45 lines (36 loc) · 1.51 KB
/
Copy pathFormFlowUtil.php
File metadata and controls
45 lines (36 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Craue\FormFlowBundle\Util;
use Craue\FormFlowBundle\Form\FormFlow;
/**
* @author Christian Raue <christian.raue@gmail.com>
* @copyright 2011-2015 Christian Raue
* @license http://opensource.org/licenses/mit-license.php MIT License
*/
class FormFlowUtil {
/**
* Adds route parameters for dynamic step navigation.
* @param array $parameters Current route parameters.
* @param FormFlow $flow The flow involved.
* @param integer|null $stepNumber Number of the step the link will be generated for. If <code>null</code>, the <code>$flow</code>'s current step number will be used.
* @return array Route parameters plus instance and step parameter.
*/
public function addRouteParameters(array $parameters, FormFlow $flow, $stepNumber = null) {
if ($stepNumber === null) {
$stepNumber = $flow->getCurrentStepNumber();
}
$parameters[$flow->getDynamicStepNavigationInstanceParameter()] = $flow->getInstanceId();
$parameters[$flow->getDynamicStepNavigationStepParameter()] = $stepNumber;
return $parameters;
}
/**
* Removes route parameters for dynamic step navigation.
* @param array $parameters Current route parameters.
* @param FormFlow $flow The flow involved.
* @return array Route parameters without instance and step parameter.
*/
public function removeRouteParameters(array $parameters, FormFlow $flow) {
unset($parameters[$flow->getDynamicStepNavigationInstanceParameter()]);
unset($parameters[$flow->getDynamicStepNavigationStepParameter()]);
return $parameters;
}
}