Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend_routing
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
frontend_routing
Commits
1f5d0746
Commit
1f5d0746
authored
11 months ago
by
Jon Minder
Browse files
Options
Downloads
Patches
Plain Diff
Refactor and use state to not resave the options.
parent
615238bd
Branches
Branches containing commit
Tags
1.0.3
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend_routing.module
+3
-3
3 additions, 3 deletions
frontend_routing.module
src/Form/SettingsForm.php
+8
-2
8 additions, 2 deletions
src/Form/SettingsForm.php
with
11 additions
and
5 deletions
frontend_routing.module
+
3
−
3
View file @
1f5d0746
...
...
@@ -23,9 +23,9 @@ function frontend_routing_form_node_form_alter(&$form, &$form_state) {
}
// Check if the alias matches for the pattern.
$
key
s
=
\Drupal
::
config
(
'frontend_routing.settings
'
)
->
get
(
'keys
'
)
??
[];
foreach
(
$
keys
as
$key
=>
$value
)
{
if
(
empty
(
$value
[
'en
tity_id
'
])
&&
!
empty
(
$value
[
'bundle'
]))
{
$
type
s
=
\Drupal
::
state
()
->
get
(
'frontend_routing.settings
_type
'
)
??
[];
foreach
(
$
types
as
$value
)
{
if
((
$value
[
'
g
en
eric
'
])
&&
!
empty
(
$value
[
'bundle'
]))
{
if
(
!
$node
->
isNew
()
&&
$node
->
bundle
()
===
$value
[
'bundle'
])
{
$form
[
'path'
][
'#access'
]
=
FALSE
;
$form
[
'path_replace'
][
'#weight'
]
=
$form
[
'path'
][
'#weight'
];
...
...
This diff is collapsed.
Click to expand it.
src/Form/SettingsForm.php
+
8
−
2
View file @
1f5d0746
...
...
@@ -63,6 +63,7 @@ final class SettingsForm extends ConfigFormBase {
$config
=
$this
->
config
(
'frontend_routing.settings'
);
$nodes
=
$this
->
state
->
get
(
'frontend_routing.settings'
)
??
[];
$types
=
$this
->
state
->
get
(
'frontend_routing.settings_type'
)
??
[];
$keys
=
$config
->
get
(
'keys'
)
??
[];
...
...
@@ -101,7 +102,7 @@ final class SettingsForm extends ConfigFormBase {
'#type'
=>
'select'
,
'#options'
=>
$this
->
getNodeTypes
(),
'#required'
=>
TRUE
,
'#default_value'
=>
!
empty
(
$
key
s
[
$key
][
'bundle'
])
?
$
key
s
[
$key
][
'bundle'
]
:
NULL
,
'#default_value'
=>
!
empty
(
$
type
s
[
$key
][
'bundle'
])
?
$
type
s
[
$key
][
'bundle'
]
:
NULL
,
];
$required
=
TRUE
;
...
...
@@ -228,6 +229,7 @@ final class SettingsForm extends ConfigFormBase {
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
):
void
{
$nodes
=
[];
$types
=
[];
// Save data from the table.
$keys
=
$this
->
config
(
'frontend_routing.settings'
)
->
get
(
'keys'
)
??
[];
...
...
@@ -257,16 +259,20 @@ final class SettingsForm extends ConfigFormBase {
$table
=
$form_state
->
getValue
(
'table'
);
if
(
is_array
(
$table
))
{
foreach
(
$table
as
$key
=>
$value
)
{
$keys
[
$key
][
'bundle'
]
=
$value
[
'bundle'
];
$types
[
$key
][
'bundle'
]
=
$value
[
'bundle'
];
$types
[
$key
][
'generic'
]
=
TRUE
;
if
(
!
empty
(
$value
[
'entity_id'
]))
{
$nodes
[
$key
]
=
$value
[
'entity_id'
];
$types
[
$key
][
'generic'
]
=
FALSE
;
}
}
$this
->
config
(
'frontend_routing.settings'
)
->
set
(
'keys'
,
$keys
)
->
save
();
}
$this
->
updateNodeAliasSetting
(
$nodes
);
$this
->
state
->
set
(
'frontend_routing.settings_type'
,
$types
);
parent
::
submitForm
(
$form
,
$form_state
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment