getBuildInfo example

$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setBuildInfo($build_info));
  }

  /** * @covers ::getBuildInfo */
  public function testGetBuildInfo() {
    $build_info = [
      'FOO' => 'BAR',
    ];

    $this->decoratedFormState->getBuildInfo()
      ->willReturn($build_info)
      ->shouldBeCalled();

    $this->assertSame($build_info$this->formStateDecoratorBase->getBuildInfo());
  }

  /** * @covers ::addBuildInfo */
  public function testAddBuildInfo() {
    $property = 'FOO';
    
      foreach ($theme_keys as $theme) {
        // Include the theme-settings.php file.         $theme_path = $this->themeHandler->getTheme($theme)->getPath();
        $theme_settings_file = $theme_path . '/theme-settings.php';
        $theme_file = $theme_path . '/' . $theme . '.theme';
        $filenames = [$theme_settings_file$theme_file];
        foreach ($filenames as $filename) {
          if (file_exists($filename)) {
            require_once $filename;

            // The file must be required for the cached form too.             $files = $form_state->getBuildInfo()['files'];
            if (!in_array($filename$files)) {
              $files[] = $filename;
            }
            $form_state->addBuildInfo('files', $files);
          }
        }

        // Call theme-specific settings.         $function = $theme . '_form_system_theme_settings_alter';
        if (function_exists($function)) {
          $function($form$form_state);
        }

    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
      // @todo static::ajaxSubmit() requires data-drupal-selector to be the same       // between the various Ajax requests. A bug in       // \Drupal\Core\Form\FormBuilder prevents that from happening unless       // $form['#id'] is also the same. Normally, #id is set to a unique HTML       // ID via Html::getUniqueId(), but here we bypass that in order to work       // around the data-drupal-selector bug. This is okay so long as we       // assume that this form only ever occurs once on a page. Remove this       // workaround in https://www.drupal.org/node/2897377.       $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);
    }
    $target_highlight_id = $this->isUpdate ? $this->sectionUpdateHighlightId($delta) : $this->sectionAddHighlightId($delta);
    $form['#attributes']['data-layout-builder-target-highlight-id'] = $target_highlight_id;

    // Mark this as an administrative page for JavaScript ("Back to site" link).     $form['#attached']['drupalSettings']['path']['currentPathIsAdmin'] = TRUE;
    return $form;
  }

  /** * {@inheritdoc} */
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';

    // static::ajaxSubmit() requires data-drupal-selector to be the same between     // the various Ajax requests. A bug in \Drupal\Core\Form\FormBuilder     // prevents that from happening unless $form['#id'] is also the same.     // Normally, #id is set to a unique HTML ID via Html::getUniqueId(), but     // here we bypass that in order to work around the data-drupal-selector bug.     // This is okay so long as we assume that this form only ever occurs once on     // a page.     // @todo Remove this workaround once https://www.drupal.org/node/2897377 is     // fixed.     $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);

    return $form;
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    if ($redirect_url = $this->getRedirectUrl()) {
      $command = new RedirectCommand($redirect_url->setAbsolute()->toString());
    }
    

  public function setBuildInfo(array $build_info) {
    $this->decoratedFormState->setBuildInfo($build_info);

    return $this;
  }

  /** * {@inheritdoc} */
  public function getBuildInfo() {
    return $this->decoratedFormState->getBuildInfo();
  }

  /** * {@inheritdoc} */
  public function addBuildInfo($property$value) {
    $this->decoratedFormState->addBuildInfo($property$value);

    return $this;
  }

  
->method('getFormId')
      ->willReturn($expected_form_id);
    $form_arg->expects($this->once())
      ->method('getBaseFormId')
      ->willReturn($base_form_id);

    $form_state = new FormState();
    $form_id = $this->formBuilder->getFormId($form_arg$form_state);

    $this->assertSame($expected_form_id$form_id);
    $this->assertSame($form_arg$form_state->getFormObject());
    $this->assertSame($base_form_id$form_state->getBuildInfo()['base_form_id']);
  }

  /** * Tests the handling of FormStateInterface::$response. * * @dataProvider formStateResponseProvider */
  public function testHandleFormStateResponse($class$form_state_key) {
    $form_id = 'test_form_id';
    $expected_form = $form_id();

    
public function isValidationComplete() {
    return $this->validation_complete;
  }

  /** * {@inheritdoc} */
  public function loadInclude($module$type$name = NULL) {
    if (!isset($name)) {
      $name = $module;
    }
    $build_info = $this->getBuildInfo();
    if (!isset($build_info['files']["$module:$name.$type"])) {
      // Only add successfully included files to the form state.       if ($result = $this->moduleLoadInclude($module$type$name)) {
        $build_info['files']["$module:$name.$type"] = [
          'type' => $type,
          'module' => $module,
          'name' => $name,
        ];
        $this->setBuildInfo($build_info);
        return $result;
      }
    }

    if ($this->isAjax()) {
      $form['actions']['submit']['#ajax']['callback'] = '::ajaxSubmit';
      // @todo static::ajaxSubmit() requires data-drupal-selector to be the same       // between the various Ajax requests. A bug in       // \Drupal\Core\Form\FormBuilder prevents that from happening unless       // $form['#id'] is also the same. Normally, #id is set to a unique HTML       // ID via Html::getUniqueId(), but here we bypass that in order to work       // around the data-drupal-selector bug. This is okay so long as we       // assume that this form only ever occurs once on a page. Remove this       // workaround in https://www.drupal.org/node/2897377.       $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);
    }

    // Mark this as an administrative page for JavaScript ("Back to site" link).     $form['#attached']['drupalSettings']['path']['currentPathIsAdmin'] = TRUE;
    return $form;
  }

  /** * Returns the label for the submit button. * * @return string * Submit label. */
'#type' => 'submit',
      '#value' => 'Save and continue',
      '#button_type' => 'primary',
    ];
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $build_info = $form_state->getBuildInfo();
    $build_info['args'][0]['parameters']['langcode'] = $form_state->getValue('langcode');
    $form_state->setBuildInfo($build_info);
  }

}
'#type' => 'value',
      '#value' => $substitutions,
    ];

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->getBuildInfo()['args'][0];

    // Call the validation method on every field handler that has it.     foreach ($view->field as $field) {
      if (method_exists($field, 'viewsFormValidate')) {
        $field->viewsFormValidate($form$form_state);
      }
    }

    // Call the validate method on every area handler that has it.     foreach (['header', 'footer'] as $area) {
      foreach ($view->{$area} as $area_handler) {
        
/** * {@inheritdoc} */
  public function getCache($form_build_id, FormStateInterface $form_state) {
    if ($form = $this->keyValueExpirableFactory->get('form')->get($form_build_id)) {
      if ((isset($form['#cache_token']) && $this->csrfToken->validate($form['#cache_token'])) || (!isset($form['#cache_token']) && $this->currentUser->isAnonymous())) {
        $this->loadCachedFormState($form_build_id$form_state);

        // Generate a new #build_id if the cached form was rendered on a         // cacheable page.         $build_info = $form_state->getBuildInfo();
        if (!empty($build_info['immutable'])) {
          $form['#build_id_old'] = $form['#build_id'];
          $form['#build_id'] = 'form-' . Crypt::randomBytesBase64();
          $form['form_build_id']['#value'] = $form['#build_id'];
          $form['form_build_id']['#id'] = $form['#build_id'];
          unset($build_info['immutable']);
          $form_state->setBuildInfo($build_info);
        }
        return $form;
      }
    }
  }
/** * {@inheritdoc} */
  public function deleteCache($form_build_id) {
    $this->formCache->deleteCache($form_build_id);
  }

  /** * {@inheritdoc} */
  public function submitForm($form_arg, FormStateInterface &$form_state) {
    $build_info = $form_state->getBuildInfo();
    if (empty($build_info['args'])) {
      $args = func_get_args();
      // Remove $form and $form_state from the arguments.       unset($args[0]$args[1]);
      $form_state->addBuildInfo('args', array_values($args));
    }

    // Populate FormState::$input with the submitted values before retrieving     // the form, to be consistent with what self::buildForm() does for     // non-programmatic submissions (form builder functions may expect it to be     // there).
/** * {@inheritdoc} */
  public function getFormId() {
    return 'system_themes_experimental_confirm_form';
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $theme = $form_state->getBuildInfo()['args'][0] ? $form_state->getBuildInfo()['args'][0] : NULL;
    $all_themes = $this->themeList->getList();
    if (!isset($all_themes[$theme])) {
      return $this->redirect('system.themes_page');
    }
    $this->messenger()->addWarning($this->t('Experimental themes are provided for testing purposes only. Use at your own risk.'));

    $dependencies = array_keys($all_themes[$theme]->requires);
    $themes = array_merge([$theme]$dependencies);
    $is_experimental = function D$theme) use ($all_themes) {
      return isset($all_themes[$theme]) && $all_themes[$theme]->isExperimental();
    };
    
Home | Imprint | This part of the site doesn't use cookies.