Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
N
node_authlink
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
node_authlink
Commits
1cd166a0
Commit
1cd166a0
authored
Aug 23, 2018
by
akalam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added custom access function
parent
fe5c2b0f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
node_authlink.routing.yml
node_authlink.routing.yml
+1
-0
src/Form/NodeAuthlinkNodeForm.php
src/Form/NodeAuthlinkNodeForm.php
+21
-0
No files found.
node_authlink.routing.yml
View file @
1cd166a0
...
...
@@ -5,5 +5,6 @@ node_authlink.node_authlink_node_form:
_title
:
'
Authlink'
requirements
:
_permission
:
'
create
and
delete
node
authlinks'
_custom_access
:
'
\Drupal\node_authlink\Form\NodeAuthlinkNodeForm::access'
options
:
_admin_route
:
TRUE
src/Form/NodeAuthlinkNodeForm.php
View file @
1cd166a0
...
...
@@ -2,8 +2,11 @@
namespace
Drupal\node_authlink\Form
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\node\Entity\Node
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
...
...
@@ -71,4 +74,22 @@ class NodeAuthlinkNodeForm extends FormBase {
}
/**
* Checks that node_authlink was enabled for this content type.
*
* @param \Drupal\Core\Session\AccountInterface $account
* @param $node
*
* @return \Drupal\Core\Access\AccessResultInterface
*/
public
function
access
(
AccountInterface
$account
,
$node
)
{
if
(
is_numeric
(
$node
))
{
$node
=
Node
::
load
(
$node
);
$enable
=
$this
->
config
(
'node_authlink.settings'
)
->
get
(
'enable'
);
if
(
isset
(
$enable
[
$node
->
bundle
()])
&&
$enable
[
$node
->
bundle
()])
{
return
AccessResult
::
allowed
();
}
}
return
AccessResult
::
forbidden
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment