WizardFormController.php in Chaos Tool Suite (ctools) 8.3
File
src/Controller/WizardFormController.php
View source
<?php
namespace Drupal\ctools\Controller;
use Drupal\Core\Controller\FormController;
use Drupal\Core\Form\FormBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\ctools\Wizard\WizardFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
class WizardFormController extends FormController {
protected $classResolver;
protected $tempstore;
protected $dispatcher;
public function __construct(ArgumentResolverInterface $argument_resolver, FormBuilderInterface $form_builder, WizardFactoryInterface $wizard_factory) {
parent::__construct($argument_resolver, $form_builder);
$this->wizardFactory = $wizard_factory;
}
protected function getFormArgument(RouteMatchInterface $route_match) {
return $route_match
->getRouteObject()
->getDefault('_wizard');
}
protected function getFormObject(RouteMatchInterface $route_match, $form_arg) {
if (!is_subclass_of($form_arg, '\\Drupal\\ctools\\Wizard\\FormWizardInterface')) {
throw new \Exception("The _wizard default must reference a class instance of \\Drupal\\ctools\\Wizard\\FormWizardInterface.");
}
$parameters = $route_match
->getParameters()
->all();
$parameters += $form_arg::getParameters();
$parameters['route_match'] = $route_match;
return $this->wizardFactory
->createWizard($form_arg, $parameters);
}
public function getContentResult(Request $request, RouteMatchInterface $route_match) {
$wizard = $this
->getFormObject($route_match, $this
->getFormArgument($route_match));
$ajax = $request->attributes
->get('js') == 'ajax' ? TRUE : FALSE;
return $this->wizardFactory
->getWizardForm($wizard, $request->attributes
->all(), $ajax);
}
}