disableLayoutBuilder example

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

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->sectionStorage->disableLayoutBuilder()->save();
    $this->layoutTempstoreRepository->delete($this->sectionStorage);

    $this->messenger()->addMessage($this->t('Layout Builder has been disabled.'));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
$data['full disabled'] = [FALSE, 'full', FALSE];
    $data['_custom enabled'] = [FALSE, '_custom', TRUE];
    $data['_custom disabled'] = [FALSE, '_custom', FALSE];
    return $data;
  }

  /** * Tests that setting overridable enables Layout Builder only when TRUE. */
  public function testSetOverridable() {
    // Disable Layout Builder.     $this->sectionList->disableLayoutBuilder();

    // Set Overridable to TRUE and ensure Layout Builder is enabled.     $this->sectionList->setOverridable();
    $this->assertTrue($this->sectionList->isLayoutBuilderEnabled());

    // Ensure Layout Builder is still enabled after setting Overridable to FALSE.     $this->sectionList->setOverridable(FALSE);
    $this->assertTrue($this->sectionList->isLayoutBuilderEnabled());
  }

}

  public function enableLayoutBuilder() {
    $this->getDisplay()->enableLayoutBuilder();
    return $this;
  }

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

  /** * {@inheritdoc} */
  public function getThirdPartySetting($module$key$default = NULL) {
    return $this->getDisplay()->getThirdPartySetting($module$key$default);
  }

  /** * {@inheritdoc} */
$field->save();
    }
  }

  /** * {@inheritdoc} */
  public function createCopy($mode) {
    // Disable Layout Builder and remove any sections copied from the original.     return parent::createCopy($mode)
      ->setSections([])
      ->disableLayoutBuilder();
  }

  /** * {@inheritdoc} */
  protected function getDefaultRegion() {
    if ($this->hasSection(0)) {
      return $this->getSection(0)->getDefaultRegion();
    }

    return parent::getDefaultRegion();
  }
Home | Imprint | This part of the site doesn't use cookies.