function WorkspaceSafeFormTrait::getSectionStorageFromFormState

Retrieves the section storage from a form state object, if it exists.

Parameters

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

Return value

\Drupal\layout_builder\SectionStorageInterface|null The section storage or NULL if it doesn't exist.

1 call to WorkspaceSafeFormTrait::getSectionStorageFromFormState()
WorkspaceSafeFormTrait::isWorkspaceSafeForm in core/modules/layout_builder/src/Form/WorkspaceSafeFormTrait.php
Determines whether the current form is safe to be submitted in a workspace.

File

core/modules/layout_builder/src/Form/WorkspaceSafeFormTrait.php, line 53

Class

WorkspaceSafeFormTrait
Provides a trait that marks Layout Builder forms as workspace-safe.

Namespace

Drupal\layout_builder\Form

Code

protected function getSectionStorageFromFormState(FormStateInterface $form_state) : ?SectionStorageInterface {
    foreach ($form_state->getBuildInfo()['args'] as $argument) {
        if ($argument instanceof SectionStorageInterface) {
            return $argument;
        }
    }
    return NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.