Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scn
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
scn
Merge requests
!5
Fixes user_role_names() deprecation
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Fixes user_role_names() deprecation
issue/scn-3472113:3472113-drupal-11-compatibility
into
2.0.x
Overview
0
Commits
3
Pipelines
0
Changes
2
Open
Nicolas Morand
requested to merge
issue/scn-3472113:3472113-drupal-11-compatibility
into
2.0.x
8 months ago
Overview
0
Commits
3
Pipelines
0
Changes
2
Expand
Closes
#3472113
0
0
Merge request reports
Compare
2.0.x
version 2
f44e77f1
8 months ago
version 1
8c9adc80
8 months ago
2.0.x (HEAD)
and
latest version
latest version
717bfebb
3 commits,
8 months ago
version 2
f44e77f1
2 commits,
8 months ago
version 1
8c9adc80
1 commit,
8 months ago
2 files
+
31
−
2
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
src/Form/SCNSettingsForm.php
+
30
−
1
Options
@@ -2,14 +2,40 @@
@@ -2,14 +2,40 @@
namespace
Drupal\scn\Form
;
namespace
Drupal\scn\Form
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\ConfigFormBase
;
use
Drupal\Core\Form\ConfigFormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\user\RoleInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
/**
* Defines a form that configures forms module settings.
* Defines a form that configures forms module settings.
*/
*/
class
SCNSettingsForm
extends
ConfigFormBase
{
class
SCNSettingsForm
extends
ConfigFormBase
{
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected
$entityTypeManager
;
/**
* {@inheritdoc}
*/
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'entity_type.manager'
)
);
}
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
@@ -50,11 +76,14 @@ class SCNSettingsForm extends ConfigFormBase {
@@ -50,11 +76,14 @@ class SCNSettingsForm extends ConfigFormBase {
'#default_value'
=>
$config
->
get
(
'scn_node_author'
),
'#default_value'
=>
$config
->
get
(
'scn_node_author'
),
'#description'
=>
$this
->
t
(
'Send mail to the Node author'
),
'#description'
=>
$this
->
t
(
'Send mail to the Node author'
),
];
];
$roles_options
=
$this
->
entityTypeManager
->
getStorage
(
'user_role'
)
->
loadMultiple
();
unset
(
$roles_options
[
RoleInterface
::
ANONYMOUS_ID
]);
$roles_options
=
array_map
(
fn
(
RoleInterface
$role
)
=>
$role
->
label
(),
$roles_options
);
$form
[
'fieldset'
][
'scn_roles'
]
=
[
$form
[
'fieldset'
][
'scn_roles'
]
=
[
'#type'
=>
'checkboxes'
,
'#type'
=>
'checkboxes'
,
'#title'
=>
$this
->
t
(
'Roles'
),
'#title'
=>
$this
->
t
(
'Roles'
),
'#default_value'
=>
!
empty
(
$roles
)
?
$roles
:
[],
'#default_value'
=>
!
empty
(
$roles
)
?
$roles
:
[],
'#options'
=>
array_map
(
'\Drupal\Component\Utility\Html::escape'
,
user_role_names
(
TRUE
))
,
'#options'
=>
$roles_options
,
'#description'
=>
$this
->
t
(
'Send mail to users with selected roles'
),
'#description'
=>
$this
->
t
(
'Send mail to users with selected roles'
),
];
];
$form
[
'fieldset'
][
'scn_maillist'
]
=
[
$form
[
'fieldset'
][
'scn_maillist'
]
=
[
Loading