private function GroupAddForm::saveGroup in Context groups 8
Same name and namespace in other branches
- 8.2 src/Form/GroupAddForm.php \Drupal\context_groups\Form\GroupAddForm::saveGroup()
Save group to database.
Parameters
FormStateInterface $form_state: FormState object.
1 call to GroupAddForm::saveGroup()
- GroupAddForm::submitForm in src/
Form/ GroupAddForm.php - Form submission handler.
File
- src/
Form/ GroupAddForm.php, line 223
Class
- GroupAddForm
- Class GroupDeleteForm.
Namespace
Drupal\context_groups\FormCode
private function saveGroup(FormStateInterface $form_state) {
// Load current context.
$cid = $form_state
->getValue('context_id');
$context = $this->entityTypeManager
->getStorage('context')
->load($cid);
// Get data of context group.
$data['name'] = $form_state
->getValue('name');
$data['label'] = $form_state
->getValue('group_name');
$data['region'] = $form_state
->getValue('region');
$data['parent'] = '';
$data['weight'] = 0;
$data['theme'] = $form_state
->getValue('theme');
$data['class'] = $form_state
->getValue('class');
// Save group to context.
$context
->setThirdPartySetting('context_groups', $form_state
->getValue('name'), $data);
// Save context.
$context
->save();
}