You are here

function node_authlink_form_node_type_form_alter_submit in Node authorize link 8

Same name and namespace in other branches
  1. 7 node_authlink.module \node_authlink_form_node_type_form_alter_submit()

Submit for node_type_form.

1 string reference to 'node_authlink_form_node_type_form_alter_submit'
node_authlink_form_node_type_form_alter in ./node_authlink.module
Alter of node_type_form.

File

./node_authlink.module, line 114
Node Authlink hooks and alters.

Code

function node_authlink_form_node_type_form_alter_submit(&$form, FormStateInterface &$form_state) {

  // Disabled
  $type = $form_state
    ->getValue('type');
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('node_authlink.settings');
  $enable = $config
    ->get('enable');
  $grants = $config
    ->get('grants');
  $expire = $config
    ->get('expire');
  if (!$form_state
    ->getValue('node_authlink_enable')) {
    unset($enable[$type]);
    unset($grants[$type]);
  }
  else {
    $enable[$type] = TRUE;
    $grants[$type] = $form_state
      ->getValue('node_authlink_grants');
  }
  $expire[$type] = $form_state
    ->getValue('node_authlink_expire');
  $config
    ->set('enable', $enable);
  $config
    ->set('grants', $grants);
  $config
    ->set('expire', $expire);
  $config
    ->save();
}