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
Commits
cbcdbcd4
Commit
cbcdbcd4
authored
4 years ago
by
Eric Bremner
Committed by
Igor Biki
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-4166: adding the confirm form for content moderation
parent
c5c8d7e0
No related branches found
No related tags found
1 merge request
!8
Feature/istwcms 4166 publish unpublish
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Form/UwContentModerationForm.php
+82
-5
82 additions, 5 deletions
src/Form/UwContentModerationForm.php
with
82 additions
and
5 deletions
src/Form/UwContentModerationForm.php
+
82
−
5
View file @
cbcdbcd4
...
...
@@ -2,14 +2,58 @@
namespace
Drupal\uw_cfg_common\Form
;
use
Drupal\Core\Form\FormBase
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\ConfirmFormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\uw_cfg_common
\UwPermissions\UwPermissions
;
use
Drupal\Core\Url
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Form class for the content access form.
*/
class
UwContentModerationForm
extends
FormBase
{
class
UwContentModerationForm
extends
ConfirmFormBase
{
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected
$entityTypeManager
;
/**
* The nid (node id).
*
* @var int
*/
protected
$nid
;
/**
* The vid (version id).
*
* @var int
*/
protected
$vid
;
/**
* Class constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public
function
__construct
(
EntityTypeManagerInterface
$entity_type_manager
)
{
$this
->
entityTypeManager
=
$entity_type_manager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
// Instantiates this form class.
return
new
static
(
$container
->
get
(
'entity_type.manager'
)
);
}
/**
* {@inheritdoc}
...
...
@@ -23,9 +67,12 @@ class UwContentModerationForm extends FormBase {
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
,
$nid
=
NULL
,
$vid
=
NULL
)
{
$form
=
[];
// Set the node and version ids.
$this
->
nid
=
$nid
;
$this
->
vid
=
$vid
;
return
$form
;
// Return the form from the parent (confirm form).
return
parent
::
buildForm
(
$form
,
$form_state
);
}
/**
...
...
@@ -36,4 +83,34 @@ class UwContentModerationForm extends FormBase {
// Set the message that the permissions have been saved.
$this
->
messenger
()
->
addStatus
(
$this
->
t
(
'The changes have been saved.'
));
}
/**
* Returns the question to ask the user.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* The form question. The page title will be set to this value.
*/
public
function
getQuestion
()
{
// Get the node object.
$node
=
$this
->
entityTypeManager
->
getStorage
(
'node'
)
->
load
(
$this
->
nid
);
// Return the question to see if they want to publish the node.
return
t
(
'Are you sure you want to unpublish %node_title?'
,
[
'%node_title'
=>
$node
->
getTitle
()]);
}
/**
* Returns the route to go to if the user cancels the action.
*
* @return \Drupal\Core\Url
* A URL object.
*/
public
function
getCancelUrl
()
{
// Set the options for the URL.
$options
=
[
'absolute'
=>
TRUE
];
// Return the URL back to the node.
return
Url
::
fromRoute
(
'entity.node.canonical'
,
[
'node'
=>
$this
->
nid
],
$options
);
}
}
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