function node_revision_delete_form_node_type_form_builder in Node Revision Delete 8
Custom form builder to save the configuration variables.
Parameters
string $entity_type: The entity type.
Drupal\node\NodeTypeInterface $type: The entity type object.
array $form: The form element.
Drupal\Core\Form\FormStateInterface $form_state: The form state.
1 string reference to 'node_revision_delete_form_node_type_form_builder'
File
- ./
node_revision_delete.module, line 166 - Contains node_revision_delete.module.
Code
function node_revision_delete_form_node_type_form_builder($entity_type, NodeTypeInterface $type, array &$form, FormStateInterface $form_state) {
// Getting the form values.
$track = $form_state
->getValue('node_revision_delete_track');
// If we will track the content type.
if ($track) {
// Saving the values in the config.
$type
->setThirdPartySetting('node_revision_delete', 'minimum_revisions_to_keep', $form_state
->getValue('minimum_revisions_to_keep'));
$type
->setThirdPartySetting('node_revision_delete', 'minimum_age_to_delete', $form_state
->getValue('minimum_age_to_delete'));
$type
->setThirdPartySetting('node_revision_delete', 'when_to_delete', $form_state
->getValue('when_to_delete'));
}
elseif (!$form_state
->getFormObject()
->getEntity()
->isNew()) {
// Deleting the values from the config.
$type
->unsetThirdPartySetting('node_revision_delete', 'minimum_revisions_to_keep');
$type
->unsetThirdPartySetting('node_revision_delete', 'minimum_age_to_delete');
$type
->unsetThirdPartySetting('node_revision_delete', 'when_to_delete');
}
}