You are here

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

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

1 call to TaxonomyTermMappings::submitForm()
rdfui_taxonomy_vocabulary_form_submit in ./rdfui.module
Handles submission the altered VocabularyForm.

File

src/TaxonomyTermMappings.php, line 66

Class

TaxonomyTermMappings
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')) {

    /** @var \Drupal\Core\Entity\EntityInterface $entity_type */
    $entity_type = $form_state
      ->getFormObject()
      ->getEntity();
    $mapping = rdf_get_mapping('taxonomy_term', $entity_type
      ->id());
    if ($entity_type
      ->isNew()) {
      $mapping = rdf_get_mapping('taxonomy_term', $form_state
        ->getValue('types'));
    }
    if ($form_state
      ->hasValue('types')) {
      $mapping
        ->setBundleMapping(array(
        'types' => array(
          $form_state
            ->getValue('types'),
        ),
      ))
        ->save();
    }
  }
}