Commit b9037434 authored by akalam's avatar akalam

Added permission

parent 4f741fb7
......@@ -14,6 +14,9 @@ use Drupal\node\NodeInterface;
*/
function node_authlink_form_node_type_form_alter(&$form, FormStateInterface &$form_state) {
if (!\Drupal::currentUser()->hasPermission('configure node_authlink module')) {
return;
}
/** @var \Drupal\node\Entity\NodeType $node_type */
$node_type = $form_state->getFormObject();
$type = $node_type->getEntity()->id();
......@@ -77,6 +80,15 @@ function node_authlink_form_node_type_form_alter(&$form, FormStateInterface &$fo
$form['actions']['submit']['#submit'][] = 'node_authlink_form_node_type_form_alter_submit';
}
/**
* Helper function to build expire options.
*
* @param array $time_intervals
* @param int $granularity
* @param null $langcode
*
* @return array
*/
function node_authlink_build_options(array $time_intervals, $granularity = 2, $langcode = NULL) {
$callback = function ($value) use ($granularity, $langcode) {
return \Drupal::service('date.formatter')->formatInterval($value, $granularity, $langcode);
......
configure node_authlink module:
title: 'Configure node_authlink module'
description: ''
create and delete node authlinks:
title: 'Create and delete node authlinks'
description: ''
......@@ -2,8 +2,8 @@ node_authlink.node_authlink_node_form:
path: 'node/{node}/authlink'
defaults:
_form: '\Drupal\node_authlink\Form\NodeAuthlinkNodeForm'
_title: 'NodeAuthlinkNodeForm'
_title: 'Authlink'
requirements:
_access: TRUE
_permission: 'create and delete node authlinks'
options:
_admin_route: FALSE
_admin_route: TRUE
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