CraueFormFlowBundle
CraueFormFlowBundle copied to clipboard
Custom Step Parameters
How about having custom step parameters like this?
public static function createFromConfig($number, array $config)
{
$step = new static();
$step->setNumber($number);
foreach ($config as $key => $value)
{
switch ($key)
{
case 'label':
$step->setLabel($value);
break;
case 'type':
@trigger_error('Step config option "type" is deprecated since version 3.0. Use "form_type" instead.', E_USER_DEPRECATED);
case 'form_type':
$step->setFormType($value);
break;
case 'form_options':
$step->setFormOptions($value);
break;
case 'skip':
$step->setSkip($value);
break;
case 'custom_parameters':
$step->setCustomParameters($value);
break;
default:
throw new \InvalidArgumentException(sprintf('Invalid step config option "%s" given.', $key));
}
}
return $step;
}
/**
* {@inheritDoc}
*/
public function getCustomParameters()
{
return $this->customParameters;
}
/**
* {@inheritDoc}
*/
public function setCustomParameters($customParameters)
{
$this->customParameters = $customParameters;
}
/**
* {@inheritDoc}
*/
public function getCustomParameter($key)
{
$customParameters = $this->getCustomParameters();
if (array_key_exists($key, $customParameters))
return $customParameters[$key];
else
throw new \InvalidArgumentException(sprintf('Invalid custom parameter "%s" requested.', $key));
}
public function hasCustomParameter($key)
{
$customParameters = $this->getCustomParameters();
return is_array($customParameters) and array_key_exists($key, $customParameters);
}
See #138.
What's the conclusion? Would you like to have this in? I also took a look at #138 & #94, which is somewhat related. I'd still vote for having explicit custom parameters like specified above - looks just simpler to me than GetStepsEvent like mentioned in this comment.