You are here

class WizardFormController in Chaos Tool Suite (ctools) 8.3

Wrapping controller for wizard forms that serve as the main page body.

Hierarchy

Expanded class hierarchy of WizardFormController

1 string reference to 'WizardFormController'
ctools.services.yml in ./ctools.services.yml
ctools.services.yml
1 service uses WizardFormController
ctools.wizard.form in ./ctools.services.yml
Drupal\ctools\Controller\WizardFormController

File

src/Controller/WizardFormController.php, line 15

Namespace

Drupal\ctools\Controller
View source
class WizardFormController extends FormController {

  /**
   * The class resolver.
   *
   * @var \Drupal\Core\DependencyInjection\ClassResolverInterface
   */
  protected $classResolver;

  /**
   * Tempstore Factory for keeping track of values in each step of the wizard.
   *
   * @var \Drupal\Core\TempStore\SharedTempStoreFactory
   */
  protected $tempstore;

  /**
   * The event dispatcher.
   *
   * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
   */
  protected $dispatcher;

  /**
   * @param \Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface $argument_resolver
   *   The argument resolver.
   * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
   *   The form builder.
   * @param \Drupal\ctools\Wizard\WizardFactoryInterface $wizard_factory
   *   The wizard factory.
   */
  public function __construct(ArgumentResolverInterface $argument_resolver, FormBuilderInterface $form_builder, WizardFactoryInterface $wizard_factory) {
    parent::__construct($argument_resolver, $form_builder);
    $this->wizardFactory = $wizard_factory;
  }

  /**
   * {@inheritdoc}
   */
  protected function getFormArgument(RouteMatchInterface $route_match) {
    return $route_match
      ->getRouteObject()
      ->getDefault('_wizard');
  }

  /**
   * Wizards are not instantiated as simply as forms, so this method is unused.
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormController::$argumentResolver protected property The argument resolver.
FormController::$controllerResolver Deprecated protected property The controller resolver.
FormController::$formBuilder protected property The form builder.
WizardFormController::$classResolver protected property The class resolver.
WizardFormController::$dispatcher protected property The event dispatcher.
WizardFormController::$tempstore protected property Tempstore Factory for keeping track of values in each step of the wizard.
WizardFormController::getContentResult public function Invokes the form and returns the result. Overrides FormController::getContentResult
WizardFormController::getFormArgument protected function Extracts the form argument string from a request. Overrides FormController::getFormArgument 1
WizardFormController::getFormObject protected function Wizards are not instantiated as simply as forms, so this method is unused. Overrides FormController::getFormObject
WizardFormController::__construct public function Overrides FormController::__construct 1