You are here

public static function BackgroundImageFormTrait::initForm in Background Image 8

Same name and namespace in other branches
  1. 2.x src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::initForm()
  2. 2.0.x src/BackgroundImageFormTrait.php \Drupal\background_image\BackgroundImageFormTrait::initForm()

Retrieves existing instance or creates new one from form state.

Parameters

array $form: The complete form render array.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state object.

Return value

self

File

src/BackgroundImageFormTrait.php, line 436

Class

BackgroundImageFormTrait
Trait BackgroundImageFormTrait.

Namespace

Drupal\background_image

Code

public static function initForm(array &$form, FormStateInterface $form_state) {

  /** @var self $self */
  $self = $form_state
    ->get(self::class);
  if (!$self) {
    $self = new self();
    $form_state
      ->set(self::class, $self);
  }
  return $self
    ->setForm($form)
    ->setFormState($form_state);
}