Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_cfg_common
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_cfg_common
Merge requests
!8
Feature/istwcms 4166 publish unpublish
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/istwcms 4166 publish unpublish
feature/ISTWCMS-4166-publish-unpublish
into
8.x-1.x
Overview
1
Commits
4
Pipelines
0
Changes
1
Merged
Eric Bremner
requested to merge
feature/ISTWCMS-4166-publish-unpublish
into
8.x-1.x
4 years ago
Overview
1
Commits
4
Pipelines
0
Changes
1
Expand
Classes to handle content moderation.
0
0
Merge request reports
Viewing commit
a59e1940
Prev
Next
Show latest version
1 file
+
39
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
a59e1940
ISTWCMS-4166: adding preprocess node to place either content moderation block
· a59e1940
Eric Bremner
authored
4 years ago
uw_cfg_common.module
+
39
−
0
Options
@@ -173,3 +173,42 @@ function uw_cfg_common_toolbar_alter(&$items) {
}
}
}
/**
* Implements hook_preprocess_node().
*/
function
uw_cfg_common_preprocess_node
(
&
$variables
)
{
// Get the current path.
$path
=
explode
(
'/'
,
\Drupal
::
service
(
'path.current'
)
->
getPath
());
// The paths to place the content moderation block on. Made this
// an array to future proof, if there are more pages later.
$paths_for_content_moderation
=
[
'latest'
];
// Check if we are to add the content moderation place.
if
(
in_array
(
end
(
$path
),
$paths_for_content_moderation
))
{
// Add the content moderation block.
$variables
[
'uw_content_moderation_form'
]
=
\Drupal
::
formBuilder
()
->
getForm
(
'Drupal\content_moderation\Form\EntityModerationForm'
,
$variables
[
'node'
]);
}
else
{
$block_manager
=
\Drupal
::
service
(
'plugin.manager.block'
);
$plugin_block
=
$block_manager
->
createInstance
(
'uw_cbl_content_moderation'
,
[]);
$access_result
=
$plugin_block
->
access
(
\Drupal
::
currentUser
());
// Return empty render array if user doesn't have access.
// $access_result can be boolean or an AccessResult class
if
(
is_object
(
$access_result
)
&&
$access_result
->
isForbidden
()
||
is_bool
(
$access_result
)
&&
!
$access_result
)
{
return
[];
}
$render
=
$plugin_block
->
build
();
$variables
[
'uw_content_moderation_form'
]
=
$render
;
}
}
Loading