protected function InsertComponentForm::insertComponent in Layout Paragraphs 2.0.x
Inserts the new component into the layout.
Determines the correct method based on provided values.
- If parent uuid and region are provided, new component is added to the specified region within the specified parent.
 - If sibling uuid and placement are provided, the new component is added before or after the existing sibling.
 - If no parameters are added, the new component is simply added to the layout at the root level.
 
Return value
$this
1 call to InsertComponentForm::insertComponent()
- InsertComponentForm::submitForm in src/
Form/ InsertComponentForm.php  - Saves the paragraph component.
 
File
- src/
Form/ InsertComponentForm.php, line 190  
Class
- InsertComponentForm
 - Class InsertComponentForm.
 
Namespace
Drupal\layout_paragraphs\FormCode
protected function insertComponent() {
  if ($this->parentUuid && $this->region) {
    $this->layoutParagraphsLayout
      ->insertIntoRegion($this->parentUuid, $this->region, $this->paragraph);
  }
  elseif ($this->siblingUuid && $this->placement) {
    switch ($this->placement) {
      case 'before':
        $this->layoutParagraphsLayout
          ->insertBeforeComponent($this->siblingUuid, $this->paragraph);
        break;
      case 'after':
        $this->layoutParagraphsLayout
          ->insertAfterComponent($this->siblingUuid, $this->paragraph);
        break;
    }
  }
  else {
    $this->layoutParagraphsLayout
      ->appendComponent($this->paragraph);
  }
  return $this;
}