diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardInterface.php b/lib/Drupal/views/Plugin/views/wizard/WizardInterface.php index 70899c80b074b70c4c252d8db72acb79a4061107..f736ba2921668660a72bc071d97310098d55dc6e 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardInterface.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardInterface.php @@ -28,17 +28,30 @@ function build_form($form, &$form_state); /** * Validate form and values. * - * @return an array of form errors. + * @param array $form + * The full wizard form array. + * @param array $form_state + * The current state of the wizard form. + * + * @return array + * An empty array if the view is valid; an array of error strings if it is + * not. */ - function validate($form, &$form_state); + function validate(array $form, array &$form_state); /** - * Create a new View from form values. + * Creates a view from values that have already been validated. + * + * @param array $form + * The full wizard form array. + * @param array $form_state + * The current state of the wizard form. * - * @return a view object. + * @return Drupal\views\View + * The created view object. * * @throws Drupal\views\Plugin\views\wizard\WizardException */ - function create_view($form, &$form_state); + function create_view(array $form, array &$form_state); } diff --git a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 22c128b0d7d6c5dfdfab70efc3436d792c69c372..9dd96fa3326c3a2f9b61bfd32bde5c5e4df4d1a2 100644 --- a/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -944,8 +944,20 @@ protected function set_override_options($options, $display, $default_display) { /** * Retrieves a validated view for a form submission. + * + * @param array $form + * The full wizard form array. + * @param array $form_state + * The current state of the wizard form. + * @param bool $unset + * Should the view be removed from the list of validated views. + * + * @return Drupal\views\View $view + * The validated view object. */ - protected function retrieve_validated_view($form, $form_state, $unset = TRUE) { + protected function retrieve_validated_view(array $form, array &$form_state, $unset = TRUE) { + // @todo Figure out why all this hashing is done. Wouldn't it be easier to + // store a single entry and that's it? $key = hash('sha256', serialize($form_state['values'])); $view = (isset($this->validated_views[$key]) ? $this->validated_views[$key] : NULL); if ($unset) { @@ -956,8 +968,15 @@ protected function retrieve_validated_view($form, $form_state, $unset = TRUE) { /** * Stores a validated view from a form submission. + * + * @param array $form + * The full wizard form array. + * @param array $form_state + * The current state of the wizard form. + * @param Drupal\views\View $view + * The validated view object. */ - protected function set_validated_view($form, $form_state, $view) { + protected function set_validated_view(array $form, array &$form_state, View $view) { $key = hash('sha256', serialize($form_state['values'])); $this->validated_views[$key] = $view; } @@ -966,11 +985,8 @@ protected function set_validated_view($form, $form_state, $view) { * Implements Drupal\views\Plugin\views\wizard\WizardInterface::validate(). * * Instantiates the view from the form submission and validates its values. - * - * @return - * TRUE if the view is valid; an array of error strings if it is not. */ - function validate($form, &$form_state) { + function validate(array $form, array &$form_state) { $view = $this->instantiate_view($form, $form_state); $errors = $view->validate(); if (!is_array($errors) || empty($errors)) { @@ -982,18 +998,11 @@ function validate($form, &$form_state) { /** * Implements Drupal\views\Plugin\views\wizard\WizardInterface::create_view(). - * - * Creates a view from values that have already been validated. - * - * @return - * The created view object. - * - * @throws Drupal\views\Plugin\views\wizard\WizardException */ - function create_view($form, &$form_state) { + function create_view(array $form, array &$form_state) { $view = $this->retrieve_validated_view($form, $form_state); if (empty($view)) { - throw new WizardException(t('Attempted to create_view with values that have not been validated')); + throw new WizardException('Attempted to create_view with values that have not been validated.'); } return $view; }