protected function ContentBuilderForm::createNodeType in Schema.org configuration tool (RDF UI) 8
Creates a new node_type.
Parameters
string $rdf_type: URI of the resource.
1 call to ContentBuilderForm::createNodeType()
- ContentBuilderForm::submitForm in rdf_builder/
src/ Form/ ContentBuilderForm.php - @inheritdoc
File
- rdf_builder/
src/ Form/ ContentBuilderForm.php, line 341
Class
Namespace
Drupal\rdf_builder\FormCode
protected function createNodeType($rdf_type) {
$type = explode(':', $rdf_type);
$type = $this->prefix . $type[1];
// Truncate if machine_name is longer than 32 char.
if (strlen($type) > 32) {
$type = substr($type, 0, 32);
}
$values = array(
'name' => $this->converter
->label($rdf_type),
'type' => strtolower($type),
'description' => $this->converter
->description($rdf_type),
);
try {
$this->entity = \Drupal::entityTypeManager()
->getStorage('node_type')
->create($values);
$this->entity
->save();
} catch (\Exception $e) {
$this
->messenger()
->addMessage($this
->t('Error saving content type %invalid.', [
'%invalid' => $rdf_type,
]));
}
}