public function WizardFactory::createWizard in Chaos Tool Suite (ctools) 8.3
Create form wizard.
Parameters
string $class: A class name implementing FormWizardInterface.
array $parameters: The array of parameters specific to this wizard.
Return value
\Drupal\ctools\Wizard\FormWizardInterface Return form Wizard.
Overrides WizardFactoryInterface::createWizard
File
- src/
Wizard/ WizardFactory.php, line 84
Class
- WizardFactory
- The wizard factory.
Namespace
Drupal\ctools\WizardCode
public function createWizard($class, array $parameters) {
$arguments = [];
$reflection = new \ReflectionClass($class);
$constructor = $reflection
->getMethod('__construct');
foreach ($constructor
->getParameters() as $parameter) {
if (array_key_exists($parameter->name, $parameters)) {
$arguments[] = $parameters[$parameter->name];
}
elseif ($parameter
->isDefaultValueAvailable()) {
$arguments[] = $parameter
->getDefaultValue();
}
}
/** @var $wizard \Drupal\ctools\Wizard\FormWizardInterface */
$wizard = $reflection
->newInstanceArgs($arguments);
return $wizard;
}