Commit fe5c2b0f authored by akalam's avatar akalam

Avoid warnings when a content type is not configured

parent b9037434
......@@ -22,6 +22,10 @@ function node_authlink_form_node_type_form_alter(&$form, FormStateInterface &$fo
$type = $node_type->getEntity()->id();
$config = \Drupal::config('node_authlink.settings');
$config_enable = $config->get('enable');
$config_grants = $config->get('grants');
$config_expire = $config->get('expire');
$form['node_authlink'] = [
'#type' => 'details',
'#title' => t('Node authorize link'),
......@@ -31,14 +35,14 @@ function node_authlink_form_node_type_form_alter(&$form, FormStateInterface &$fo
$form['node_authlink']['node_authlink_enable'] = [
'#type' => 'checkbox',
'#title' => t('Enable'),
'#default_value' => $config->get('enable.' . $type),
'#default_value' => isset($config_enable[$type])? $config_enable[$type] : 0,
'#description' => t('Disable of this feature will cost erase of authorization keys of all nodes in this node type.'),
];
$form['node_authlink']['node_authlink_grants'] = [
'#type' => 'checkboxes',
'#title' => t('Grants to give'),
'#default_value' => $config->get('grants.' . $type),
'#default_value' => isset($config_grants[$type])? $config_grants[$type] : [],
'#options' => [
'view' => t('View'),
'update' => t('Update'),
......@@ -55,7 +59,7 @@ function node_authlink_form_node_type_form_alter(&$form, FormStateInterface &$fo
$form['node_authlink']['node_authlink_expire'] = [
'#type' => 'select',
'#title' => t('Regenerate authkeys after'),
'#default_value' => $config->get('expire.' . $type),
'#default_value' => isset($config_expire[$type])? $config_expire[$type] : '',
'#options' => $period,
'#description' => t('Keys older than selected time will be regenerated by cron run.'),
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment