public function ContentBuilderForm::submitForm in Schema.org configuration tool (RDF UI) 8
@inheritdoc
Final submit handler- gather all data together and create new content type.
Overrides FormInterface::submitForm
File
- rdf_builder/
src/ Form/ ContentBuilderForm.php, line 307
Class
Namespace
Drupal\rdf_builder\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->prefix = $this
->randomString(4);
$this->properties = array();
foreach ($form_state
->getValue('fields') as $key => $property) {
if ($property['enable'] == 1) {
$this->properties[$key] = $property;
}
}
$page_one_values = $form_state
->get([
'page_values',
1,
]);
$rdf_type = $page_one_values['rdf-type'];
$this
->createNodeType($rdf_type);
$this->rdfMapping = rdf_get_mapping('node', $this->entity
->id());
$this->rdfMapping
->setBundleMapping(array(
'types' => array(
$rdf_type,
),
));
$this
->createField();
$this->rdfMapping
->save();
$this
->messenger()
->addMessage($this
->t('Content Type %label created', [
'%label' => $this->entity
->label(),
]));
/*@TODO Revert all saved content type and fields in case of error*/
$form_state
->setRedirectUrl(new Url('entity.node.field_ui_fields', array(
'node_type' => $this->entity
->id(),
)));
}