setBuildInfo example

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

  /** * {@inheritdoc} */
  public function setBuildInfo(array $build_info) {
    $this->decoratedFormState->setBuildInfo($build_info);

    return $this;
  }

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

  
'#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);
  }

}
$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;
      }
    }
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function getCacheableArray() {
    return [
      
$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;
      }
    }
  }

  /** * Loads the cached form state. * * @param string $form_build_id * The unique form build ID. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */

  }

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

    $this->decoratedFormState->setBuildInfo($build_info)
      ->shouldBeCalled();

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

  /** * @covers ::getBuildInfo */
  public function testGetBuildInfo() {
    $build_info = [
      'FOO' => 'BAR',
    ];
Home | Imprint | This part of the site doesn't use cookies.