You are here

public function BrowserGroupList::addGroup in Paragraphs Browser 8

Adds group to end of groups list, resets weight to heaviest.

Parameters

string $machine_name:

string $label:

integer $weight:

Return value

\Drupal\paragraphs_browser\BrowserGroupItem

File

src/BrowserGroupList.php, line 70

Class

BrowserGroupList

Namespace

Drupal\paragraphs_browser

Code

public function addGroup($machine_name, $label, $weight = null) {
  if (is_null($weight)) {
    $weight = ($last_group = $this
      ->getLastGroup()) ? $last_group
      ->getWeight() + 1 : 0;
  }
  $this->groups[$machine_name] = new BrowserGroupItem($machine_name, $label, $weight);
  return $this->groups[$machine_name];
}