You are here

protected function TagSetForm::copyFormValuesToEntity in Extensible BBCode 8.3

Same name and namespace in other branches
  1. 4.0.x src/Form/TagSetForm.php \Drupal\xbbcode\Form\TagSetForm::copyFormValuesToEntity()

Copies top-level form values to entity properties

This should not change existing entity properties that are not being edited by this form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides EntityForm::copyFormValuesToEntity

File

src/Form/TagSetForm.php, line 268

Class

TagSetForm
Base form for tag sets.

Namespace

Drupal\xbbcode\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) : void {
  parent::copyFormValuesToEntity($entity, $form, $form_state);
  $enabled = array_keys(array_filter($form_state
    ->getValue('_tags')));
  $settings =& $form_state
    ->getValue('_settings');
  $tags = [];
  foreach ($enabled as $key) {
    $row = $settings[$key];
    $tags[$row['name']] = $this
      ->buildPluginConfiguration($row);
  }

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  $entity
    ->set('tags', $tags);
}