hasSection example

if ($this->hasBlankSection()) {
      return 0;
    }

    return count($this->getSections());
  }

  /** * {@inheritdoc} */
  public function getSection($delta) {
    if (!$this->hasSection($delta)) {
      throw new \OutOfBoundsException(sprintf('Invalid delta "%s"', $delta));
    }

    return $this->getSections()[$delta];
  }

  /** * Sets the section for the given delta on the display. * * @param int $delta * The delta of the section. * @param \Drupal\layout_builder\Section $section * The layout section. * * @return $this */
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();
  }

  /** * Wraps the context repository service. * * @return \Drupal\Core\Plugin\Context\ContextRepositoryInterface * The context repository service. */
Home | Imprint | This part of the site doesn't use cookies.