Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
userprotect
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
userprotect
Merge requests
!3
Issue
#3349663
: Error: Call to a member function grantPermission() on null in userprotect_install()
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3349663
: Error: Call to a member function grantPermission() on null in userprotect_install()
issue/userprotect-3349663:3349663-grantpermission-null
into
8.x-1.x
Overview
0
Commits
3
Pipelines
3
Changes
1
Merged
Theodoros Ploumis
requested to merge
issue/userprotect-3349663:3349663-grantpermission-null
into
8.x-1.x
2 years ago
Overview
0
Commits
3
Pipelines
3
Changes
1
Expand
Closes
#3349663
0
0
Merge request reports
Compare
8.x-1.x
version 3
b1e651bd
1 year ago
version 2
6f8e07f6
1 year ago
version 1
2fda7d45
2 years ago
8.x-1.x (base)
and
latest version
latest version
b1e651bd
3 commits,
11 months ago
version 3
b1e651bd
3 commits,
1 year ago
version 2
6f8e07f6
2 commits,
1 year ago
version 1
2fda7d45
1 commit,
2 years ago
1 file
+
14
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
userprotect.install
+
14
−
7
Options
@@ -5,17 +5,24 @@
* Install, update and uninstall functions for the userprotect module.
*/
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\user\Entity\Role
;
use
Drupal\user\RoleInterface
;
/**
* Implements hook_install().
*
* Installs default userprotect permissions for authenticated users.
*/
function
userprotect_install
()
{
$role
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'user_role'
)
->
load
(
AccountInterface
::
AUTHENTICATED_ROLE
);
$role
->
grantPermission
(
'userprotect.mail.edit'
);
$role
->
grantPermission
(
'userprotect.pass.edit'
);
$role
->
grantPermission
(
'userprotect.account.edit'
);
$role
->
save
();
function
userprotect_install
(
$is_syncing
)
{
if
(
$is_syncing
)
{
return
;
}
$role
=
Role
::
load
(
RoleInterface
::
AUTHENTICATED_ID
);
if
(
$role
instanceof
RoleInterface
)
{
$role
->
grantPermission
(
'userprotect.mail.edit'
);
$role
->
grantPermission
(
'userprotect.pass.edit'
);
$role
->
grantPermission
(
'userprotect.account.edit'
);
$role
->
trustData
()
->
save
();
}
}
Loading