You are here

public static function ContentMappings::submitForm in Schema.org configuration tool (RDF UI) 8

Saves Schema.org mappings in \Drupal\node\NodeTypeForm.

1 call to ContentMappings::submitForm()
rdfui_node_type_form_submit in ./rdfui.module
Handles submission the altered NodeTypeForm.

File

src/ContentMappings.php, line 65

Class

ContentMappings
RDF UI Rdf Mapping for Content Types.

Namespace

Drupal\rdfui

Code

public static function submitForm(array &$form, FormStateInterface $form_state) {
  if ($form_state
    ->hasValue('types')) {
    $entity_type = $form_state
      ->getFormObject()
      ->getEntity();
    $mapping = rdf_get_mapping('node', $entity_type
      ->id());
    if ($entity_type
      ->isNew()) {
      $mapping = rdf_get_mapping('node', $form_state
        ->getValue('types'));
    }
    if ($form_state
      ->hasValue('types')) {
      $mapping
        ->setBundleMapping(array(
        'types' => array(
          $form_state
            ->getValue('types'),
        ),
      ))
        ->save();
    }
  }
}