Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
admin_audit_trail
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
admin_audit_trail
Commits
e511649f
Commit
e511649f
authored
1 year ago
by
Mikko Rantanen
Committed by
Rajab Natshah
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3278358
by mikran: Fix custom menu link translations on insert, update, and when deleted
parent
c03703c9
No related branches found
No related tags found
1 merge request
!4
Issue #3278358 by mikran: Fix custom menu link translations on insert, update, and when deleted
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
admin_audit_trail_menu/admin_audit_trail_menu.module
+57
-67
57 additions, 67 deletions
admin_audit_trail_menu/admin_audit_trail_menu.module
with
57 additions
and
67 deletions
admin_audit_trail_menu/admin_audit_trail_menu.module
+
57
−
67
View file @
e511649f
...
...
@@ -15,77 +15,10 @@ function admin_audit_trail_menu_admin_audit_trail_handlers() {
$handlers
[
'menu'
]
=
[
'title'
=>
t
(
'Menu'
),
'form_ids'
=>
[
'menu_link_content_menu_link_content_form'
,
'menu_link_content_menu_link_content_delete_form'
,
],
'form_submit_callback'
=>
'admin_audit_trail_menu_form_submit'
,
];
return
$handlers
;
}
/**
* Event log callback for the user authentication event log.
*
* @return array
* Return an associative array to log data in database.
*/
function
admin_audit_trail_menu_form_submit
(
array
&
$form
,
FormStateInterface
$form_state
,
$form_id
)
{
$log
=
NULL
;
switch
(
$form_id
)
{
case
'menu_link_content_menu_link_content_form'
:
$menu
=
$form_state
->
getValues
();
$get_title
=
$menu
[
'title'
][
0
][
'value'
];
$get_path
=
$menu
[
'link'
][
0
][
'uri'
];
$get_menu_parent
=
substr
(
$menu
[
'menu_parent'
],
0
,
-
1
);
$route_parameters
=
\Drupal
::
routeMatch
()
->
getParameter
(
'menu_link_content'
);
if
(
empty
(
$route_parameters
))
{
// Insert Menu Link.
$log
=
[
'operation'
=>
'link insert'
,
'description'
=>
t
(
'%title, %path'
,
[
'%title'
=>
$get_title
,
'%path'
=>
$get_path
,
]),
'ref_char'
=>
$get_menu_parent
,
];
}
else
{
// Update Menu Link.
$log
=
[
'operation'
=>
'link update'
,
'description'
=>
t
(
'%title (%id), %path'
,
[
'%title'
=>
$get_title
,
'%id'
=>
$route_parameters
->
get
(
'id'
)
->
value
,
'%path'
=>
$get_path
,
]),
'ref_numeric'
=>
$route_parameters
->
get
(
'id'
)
->
value
,
'ref_char'
=>
$route_parameters
->
getMenuName
(),
];
}
break
;
case
'menu_link_content_menu_link_content_delete_form'
:
// Delete Menu Link.
$route_parameters
=
\Drupal
::
routeMatch
()
->
getParameter
(
'menu_link_content'
);
$uri
=
$route_parameters
->
get
(
'link'
)
->
uri
;
$log
=
[
'operation'
=>
'link delete'
,
'description'
=>
t
(
'%title (%id), %path'
,
[
'%title'
=>
$route_parameters
->
getTitle
(),
'%id'
=>
$route_parameters
->
get
(
'id'
)
->
value
,
'%path'
=>
$uri
,
]),
'ref_numeric'
=>
$route_parameters
->
get
(
'id'
)
->
value
,
'ref_char'
=>
$route_parameters
->
getMenuName
(),
];
break
;
}
return
$log
;
}
/**
* Implements hook_menu_insert().
*/
...
...
@@ -133,3 +66,60 @@ function admin_audit_trail_menu_menu_delete($menu) {
];
admin_audit_trail_insert
(
$log
);
}
/**
* Implements hook_menu_link_insert().
*/
function
admin_audit_trail_menu_menu_link_content_insert
(
$link
)
{
$log
=
[
'type'
=>
'menu'
,
'operation'
=>
'link insert'
,
'description'
=>
t
(
'%title (%id), %path'
,
[
'%title'
=>
$link
->
getTitle
(),
'%id'
=>
$link
->
id
(),
'%path'
=>
$link
->
get
(
'link'
)
->
uri
,
]),
'ref_numeric'
=>
$link
->
id
(),
'ref_char'
=>
$link
->
getMenuName
(),
];
admin_audit_trail_insert
(
$log
);
}
/**
* Implements hook_menu_link_update().
*/
function
admin_audit_trail_menu_menu_link_content_update
(
$link
)
{
$log
=
[
'type'
=>
'menu'
,
'operation'
=>
'link update'
,
'description'
=>
t
(
'%title (%id), %path'
,
[
'%title'
=>
$link
->
getTitle
(),
'%id'
=>
$link
->
id
(),
'%path'
=>
$link
->
get
(
'link'
)
->
uri
,
]),
'ref_numeric'
=>
$link
->
id
(),
'ref_char'
=>
$link
->
getMenuName
(),
];
admin_audit_trail_insert
(
$log
);
}
/**
* Implements hook_menu_link_delete().
*/
function
admin_audit_trail_menu_menu_link_content_delete
(
$link
)
{
$log
=
[
'type'
=>
'menu'
,
'operation'
=>
'link delete'
,
'description'
=>
t
(
'%title (%id), %path'
,
[
'%title'
=>
$link
->
getTitle
(),
'%id'
=>
$link
->
id
(),
'%path'
=>
$link
->
get
(
'link'
)
->
uri
,
]),
'ref_numeric'
=>
$link
->
id
(),
'ref_char'
=>
$link
->
getMenuName
(),
];
admin_audit_trail_insert
(
$log
);
}
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