Commit 95019fa6 authored by alexpott's avatar alexpott
Browse files

Issue #2318827 by larowlan, thehong | mgifford: Fixed Can't unpublish a comment.

parent 36675eaa
...@@ -114,7 +114,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -114,7 +114,7 @@ public function form(array $form, FormStateInterface $form_state) {
// Prepare default values for form elements. // Prepare default values for form elements.
if ($is_admin) { if ($is_admin) {
$author = $comment->getAuthorName(); $author = $comment->getAuthorName();
$status = $comment->isPublished(); $status = $comment->getStatus();
if (empty($form_state['comment_preview'])) { if (empty($form_state['comment_preview'])) {
$form['#title'] = $this->t('Edit comment %title', array( $form['#title'] = $this->t('Edit comment %title', array(
'%title' => $comment->getSubject(), '%title' => $comment->getSubject(),
......
...@@ -212,6 +212,14 @@ public function getChangedTime(); ...@@ -212,6 +212,14 @@ public function getChangedTime();
*/ */
public function isPublished(); public function isPublished();
/**
* Returns the comment's status.
*
* @return int
* One of CommentInterface::PUBLISHED or CommentInterface::NOT_PUBLISHED
*/
public function getStatus();
/** /**
* Sets the published status of the comment entity. * Sets the published status of the comment entity.
* *
......
...@@ -471,6 +471,13 @@ public function isPublished() { ...@@ -471,6 +471,13 @@ public function isPublished() {
return $this->get('status')->value == CommentInterface::PUBLISHED; return $this->get('status')->value == CommentInterface::PUBLISHED;
} }
/**
* {@inheritdoc}
*/
public function getStatus() {
return $this->get('status')->value;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -136,6 +136,8 @@ function testApprovalNodeInterface() { ...@@ -136,6 +136,8 @@ function testApprovalNodeInterface() {
$this->assertResponse(403, 'Forged comment approval was denied.'); $this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged'))); $this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged')));
$this->assertResponse(403, 'Forged comment approval was denied.'); $this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('comment/1/edit');
$this->assertFieldChecked('edit-status-0');
$this->drupalGet('node/' . $this->node->id()); $this->drupalGet('node/' . $this->node->id());
$this->clickLink(t('Approve')); $this->clickLink(t('Approve'));
$this->drupalLogout(); $this->drupalLogout();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment