Commit fd2613d2 authored by alexpott's avatar alexpott

Issue #2169361 by plopesc: Convert COMMENT_HIDDEN & COMMENT_CLOSED &...

Issue #2169361 by plopesc: Convert COMMENT_HIDDEN & COMMENT_CLOSED & COMMENT_OPEN  to a constant on the comment field interface.
parent 6940175e
......@@ -10,9 +10,10 @@
* book page, user etc.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\field\FieldInstanceConfigInterface;
use Drupal\field\FieldConfigInterface;
......@@ -55,21 +56,6 @@
*/
const COMMENT_FORM_BELOW = 1;
/**
* Comments for this entity are hidden.
*/
const COMMENT_HIDDEN = 0;
/**
* Comments for this entity are closed.
*/
const COMMENT_CLOSED = 1;
/**
* Comments for this entity are open.
*/
const COMMENT_OPEN = 2;
/**
* The time cutoff for comments marked as read for entity types other node.
*
......@@ -240,7 +226,7 @@ function comment_field_instance_config_create(FieldInstanceConfigInterface $inst
}
$instance->default_value += array(array());
$instance->default_value[0] += array(
'status' => COMMENT_OPEN,
'status' => CommentItemInterface::OPEN,
'cid' => 0,
'last_comment_timestamp' => 0,
'last_comment_name' => '',
......@@ -474,7 +460,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array
}
}
// Provide a link to new comment form.
if ($commenting_status == COMMENT_OPEN) {
if ($commenting_status == CommentItemInterface::OPEN) {
$comment_form_location = $instance->getSetting('form_location');
if (user_access('post comments')) {
$links['comment-add'] = array(
......@@ -505,7 +491,7 @@ function comment_node_links_alter(array &$node_links, NodeInterface $node, array
else {
// Node in other view modes: add a "post comment" link if the user is
// allowed to post comments and if this node is allowing new comments.
if ($commenting_status == COMMENT_OPEN) {
if ($commenting_status == CommentItemInterface::OPEN) {
$comment_form_location = $instance->getSetting('form_location');
if (user_access('post comments')) {
// Show the "post comment" link if the form is on another page, or
......@@ -1054,8 +1040,8 @@ function comment_node_search_result(EntityInterface $node) {
}
// Do not make a string if comments are hidden.
$status = $node->get($field_name)->status;
if (\Drupal::currentUser()->hasPermission('access comments') && $status != COMMENT_HIDDEN) {
if ($status == COMMENT_OPEN) {
if (\Drupal::currentUser()->hasPermission('access comments') && $status != CommentItemInterface::HIDDEN) {
if ($status == CommentItemInterface::OPEN) {
// At least one comment field is open.
$open = TRUE;
}
......@@ -1320,7 +1306,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) {
// the value back to its original state after the call to entity_view().
$field_name = $comment->getFieldName();
$original_status = $entity->get($field_name)->status;
$entity->get($field_name)->status = COMMENT_HIDDEN;
$entity->get($field_name)->status = CommentItemInterface::HIDDEN;
$build = entity_view($entity, 'full');
$entity->get($field_name)->status = $original_status;
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
......@@ -380,7 +381,7 @@ public function save(array $form, array &$form_state) {
$field_name = $comment->getFieldName();
$uri = $entity->urlInfo();
if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == COMMENT_OPEN)) {
if ($this->currentUser->hasPermission('post comments') && ($this->currentUser->hasPermission('administer comments') || $entity->{$field_name}->status == CommentItemInterface::OPEN)) {
// Save the anonymous user information to a cookie for reuse.
if ($this->currentUser->isAnonymous()) {
user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage'))));
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Utility\String;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
......@@ -138,7 +139,7 @@ public function getAllFields() {
/**
* {@inheritdoc}
*/
public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN) {
public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN) {
// Make sure the field doesn't already exist.
if (!$this->fieldInfo->getField($entity_type, $field_name)) {
// Add a default comment field for existing node comments.
......
......@@ -8,6 +8,8 @@
namespace Drupal\comment;
use Drupal\Core\Entity\EntityInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Comment manager contains common functions to manage comment fields.
*/
......@@ -59,10 +61,11 @@ public function getAllFields();
* @param string $field_name
* (optional) Field name to use for the comment field. Defaults to 'comment'.
* @param int $default_value
* (optional) Default value, one of COMMENT_HIDDEN, COMMENT_OPEN,
* COMMENT_CLOSED. Defaults to COMMENT_OPEN.
* (optional) Default value, one of CommentItemInterface::HIDDEN,
* CommentItemInterface::OPEN, CommentItemInterface::CLOSED. Defaults to
* CommentItemInterface::OPEN.
*/
public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN);
public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN);
/**
* Creates a comment_body field instance.
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Access\CsrfTokenGenerator;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
......@@ -209,7 +210,7 @@ protected static function buildLinks(CommentInterface $entity, EntityInterface $
$container = \Drupal::getContainer();
if ($status == COMMENT_OPEN) {
if ($status == CommentItemInterface::OPEN) {
if ($entity->access('delete')) {
$links['comment-delete'] = array(
'title' => t('Delete'),
......
......@@ -9,6 +9,7 @@
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\field\FieldInfo;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityInterface;
......@@ -225,7 +226,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_
// The user is not just previewing a comment.
if ($request->request->get('op') != $this->t('Preview')) {
$status = $entity->{$field_name}->status;
if ($status != COMMENT_OPEN) {
if ($status != CommentItemInterface::OPEN) {
drupal_set_message($this->t("This discussion is closed: you can't post new comments."), 'error');
return $this->redirect($uri['route_name'], $uri['route_parameters']);
}
......@@ -252,7 +253,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_
elseif ($entity->access('view', $account)) {
// We make sure the field value isn't set so we don't end up with a
// redirect loop.
$entity->{$field_name}->status = COMMENT_HIDDEN;
$entity->{$field_name}->status = CommentItemInterface::HIDDEN;
// Render array of the entity full view mode.
$build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full');
unset($build['commented_entity']['#cache']);
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\Field\FieldFormatter;
use Drupal\comment\CommentStorageControllerInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityViewBuilderInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -115,7 +116,7 @@ public function viewElements(FieldItemListInterface $items) {
$status = $items->status;
if ($status != COMMENT_HIDDEN && empty($entity->in_preview) &&
if ($status != CommentItemInterface::HIDDEN && empty($entity->in_preview) &&
// Comments are added to the search results and search index by
// comment_node_update_index() instead of by this formatter, so don't
// return anything if the view mode is search_index or search_result.
......@@ -144,7 +145,7 @@ public function viewElements(FieldItemListInterface $items) {
// Append comment form if the comments are open and the form is set to
// display below the entity. Do not show the form for the print view mode.
if ($status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW && $this->viewMode != 'print') {
if ($status == CommentItemInterface::OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW && $this->viewMode != 'print') {
// Only show the add comment form if the user has permission.
if ($this->currentUser->hasPermission('post comments')) {
// All users in the "anonymous" role can use the same form: it is fine
......
......@@ -33,7 +33,7 @@
* default_formatter = "comment_default"
* )
*/
class CommentItem extends ConfigFieldItemBase {
class CommentItem extends ConfigFieldItemBase implements CommentItemInterface {
/**
* {@inheritdoc}
......@@ -170,8 +170,9 @@ public function __get($name) {
* {@inheritdoc}
*/
public function isEmpty() {
// There is always a value for this field, it is one of COMMENT_OPEN,
// COMMENT_CLOSED or COMMENT_HIDDEN.
// There is always a value for this field, it is one of
// CommentItemInterface::OPEN, CommentItemInterface::CLOSED or
// CommentItemInterface::HIDDEN.
return FALSE;
}
......
<?php
/**
* @file
* Contains \Drupal\comment\Plugin\Field\FieldType\CommentItemInterface.
*/
namespace Drupal\comment\Plugin\Field\FieldType;
use Drupal\Core\Field\ConfigFieldItemInterface;
/**
* Interface definition for Comment items.
*/
interface CommentItemInterface extends ConfigFieldItemInterface {
/**
* Comments for this entity are hidden.
*/
const HIDDEN = 0;
/**
* Comments for this entity are closed.
*/
const CLOSED = 1;
/**
* Comments for this entity are open.
*/
const OPEN = 2;
}
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\Field\FieldWidget;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
......@@ -40,17 +41,17 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
'#title_display' => 'invisible',
'#default_value' => $status,
'#options' => array(
COMMENT_OPEN => t('Open'),
COMMENT_CLOSED => t('Closed'),
COMMENT_HIDDEN => t('Hidden'),
CommentItemInterface::OPEN => t('Open'),
CommentItemInterface::CLOSED => t('Closed'),
CommentItemInterface::HIDDEN => t('Hidden'),
),
COMMENT_OPEN => array(
CommentItemInterface::OPEN => array(
'#description' => t('Users with the "Post comments" permission can post comments.'),
),
COMMENT_CLOSED => array(
CommentItemInterface::CLOSED => array(
'#description' => t('Users cannot post comments, but existing comments will be displayed.'),
),
COMMENT_HIDDEN => array(
CommentItemInterface::HIDDEN => array(
'#description' => t('Comments are hidden from view.'),
),
);
......@@ -58,9 +59,9 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
// sense, so don't even bother presenting it to the user unless this is the
// default value widget on the field settings form.
if ($element['#field_parents'] != array('default_value_input') && !$entity->get($field->getName())->comment_count) {
$element['status'][COMMENT_HIDDEN]['#access'] = FALSE;
$element['status'][CommentItemInterface::HIDDEN]['#access'] = FALSE;
// Also adjust the description of the "closed" option.
$element['status'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.');
$element['status'][CommentItemInterface::CLOSED]['#description'] = t('Users cannot post comments.');
}
// If the advanced settings tabs-set is available (normally rendered in the
// second column on wide-resolutions), place the field as a details element
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
......@@ -25,12 +26,12 @@ class NodeComment extends FieldPluginBase {
public function render(ResultRow $values) {
$value = $this->getValue($values);
switch ($value) {
case COMMENT_HIDDEN:
case CommentItemInterface::HIDDEN:
default:
return t('Hidden');
case COMMENT_CLOSED:
case CommentItemInterface::CLOSED:
return t('Closed');
case COMMENT_OPEN:
case CommentItemInterface::OPEN:
return t('Open');
}
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\filter;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\views\Plugin\views\filter\InOperator;
/**
......@@ -20,9 +21,9 @@ class NodeComment extends InOperator {
public function getValueOptions() {
$this->value_options = array(
COMMENT_HIDDEN => t('Hidden'),
COMMENT_CLOSED => t('Closed'),
COMMENT_OPEN => t('Open'),
CommentItemInterface::HIDDEN => t('Hidden'),
CommentItemInterface::CLOSED => t('Closed'),
CommentItemInterface::OPEN => t('Open'),
);
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Tests fields on comments.
*/
......@@ -58,10 +60,10 @@ function testCommentDefaultFields() {
$instances = $this->container->get('field.info')->getInstances('comment');
$this->assertTrue(isset($instances['node__comment']['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name)));
// Test adding a field that defaults to COMMENT_CLOSED.
$this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', COMMENT_CLOSED);
// Test adding a field that defaults to CommentItemInterface::CLOSED.
$this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED);
$field = entity_load('field_instance_config', 'node.test_node_type.who_likes_ponies');
$this->assertEqual($field->default_value[0]['status'], COMMENT_CLOSED);
$this->assertEqual($field->default_value[0]['status'], CommentItemInterface::CLOSED);
}
/**
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Tests the comment module administrative and end-user-facing interfaces.
......@@ -154,21 +155,21 @@ function testCommentInterface() {
$this->assertText(t('The comment you are replying to does not exist.'), 'Replying to an unpublished comment');
// Attempt to post to node with comments disabled.
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_HIDDEN))));
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::HIDDEN))));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertText('This discussion is closed', 'Posting to node with comments disabled');
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with read-only comments.
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_CLOSED))));
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::CLOSED))));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertText('This discussion is closed', 'Posting to node with comments read-only');
$this->assertNoField('edit-comment', 'Comment body field found.');
// Attempt to post to node with comments enabled (check field names etc).
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => COMMENT_OPEN))));
$this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::OPEN))));
$this->assertTrue($this->node, 'Article node created.');
$this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment');
$this->assertNoText('This discussion is closed', 'Posting to node with comments enabled');
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\simpletest\WebTestBase;
/**
......@@ -97,7 +98,7 @@ function testCommentLanguage() {
'title[0][value]' => $title,
'body[0][value]' => $this->randomName(),
'langcode' => $node_langcode,
'comment[0][status]' => COMMENT_OPEN,
'comment[0][status]' => CommentItemInterface::OPEN,
);
$this->drupalPostForm("node/add/article", $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($title);
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Language\Language;
use Drupal\comment\CommentInterface;
......@@ -68,7 +69,7 @@ function testCommentLinks() {
// test; there is only a difference between open and closed registration.
'user_register' => array(USER_REGISTER_VISITORS, USER_REGISTER_ADMINISTRATORS_ONLY),
// @todo Complete test coverage for:
//'comments' => array(COMMENT_OPEN, COMMENT_CLOSED, COMMENT_HIDDEN),
//'comments' => array(CommentItemInterface::OPEN, CommentItemInterface::CLOSED, CommentInterface::_HIDDEN),
//// COMMENT_ANONYMOUS_MUST_CONTACT is irrelevant for this test.
//'contact ' => array(COMMENT_ANONYMOUS_MAY_CONTACT, COMMENT_ANONYMOUS_MAYNOT_CONTACT),
);
......@@ -95,7 +96,8 @@ function testCommentLinks() {
* USER_REGISTER_VISITORS.
* - contact: COMMENT_ANONYMOUS_MAY_CONTACT or
* COMMENT_ANONYMOUS_MAYNOT_CONTACT.
* - comments: COMMENT_OPEN, COMMENT_CLOSED, or COMMENT_HIDDEN.
* - comments: CommentItemInterface::OPEN, CommentItemInterface::CLOSED or
* CommentItemInterface::HIDDEN.
* - User permissions:
* These are granted or revoked for the user, according to the
* 'authenticated' flag above. Pass 0 or 1 as parameter values. See
......@@ -116,7 +118,7 @@ function setEnvironment(array $info) {
'form' => COMMENT_FORM_BELOW,
'user_register' => USER_REGISTER_VISITORS,
'contact' => COMMENT_ANONYMOUS_MAY_CONTACT,
'comments' => COMMENT_OPEN,
'comments' => CommentItemInterface::OPEN,
'access comments' => 0,
'post comments' => 0,
// Enabled by default, because it's irrelevant for this test.
......@@ -191,9 +193,9 @@ function setEnvironment(array $info) {
COMMENT_ANONYMOUS_MUST_CONTACT => 'required',
);
$t_comments = array(
COMMENT_OPEN => 'open',
COMMENT_CLOSED => 'closed',
COMMENT_HIDDEN => 'hidden',
CommentItemInterface::OPEN => 'open',
CommentItemInterface::CLOSED => 'closed',
CommentItemInterface::HIDDEN => 'hidden',
);
$verbose = $info;
$verbose['form'] = $t_form[$info['form']];
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\Core\Entity\EntityInterface;
......@@ -342,7 +343,7 @@ function testCommentFunctionality() {
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-2');
// Test comment option change in field settings.
$edit = array('default_value_input[comment][0][status]' => COMMENT_CLOSED);
$edit = array('default_value_input[comment][0][status]' => CommentItemInterface::CLOSED);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Tests for Comment module integration with RSS feeds.
*/
......@@ -39,7 +41,7 @@ function testCommentRss() {
$this->assertRaw($raw, 'Comments as part of RSS feed.');
// Hide comments from RSS feed and check presence.
$this->node->set('comment', COMMENT_HIDDEN);
$this->node->set('comment', CommentItemInterface::HIDDEN);
$this->node->save();
$this->drupalGet('rss.xml');
$this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.');
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\content_translation\Tests\ContentTranslationUITest;
/**
......@@ -102,7 +103,7 @@ protected function createEntity($values, $langcode, $node_bundle = 'node__commen
$node = $this->drupalCreateNode(array(
'type' => $node_type,
$field_name => array(
array('status' => COMMENT_OPEN)
array('status' => CommentItemInterface::OPEN)
),
));
$values['entity_id'] = $node->id();
......
......@@ -5,8 +5,6 @@
* Install, update, and uninstall functions for the Forum module.
*/
use Drupal\Core\Language\Language;
/**
* Implements hook_install().
*/
......@@ -83,7 +81,7 @@ function forum_install() {
'include_deleted' => FALSE,
));
if (empty($fields)) {
Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum', COMMENT_OPEN);
Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum');
}
}
......
......@@ -5,6 +5,7 @@
* Provides discussion forums.
*/
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Utility\String;
use Drupal\field\Field;
......@@ -805,7 +806,7 @@ function template_preprocess_forum_icon(&$variables) {
$variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic');
}
if ($variables['comment_mode'] == COMMENT_CLOSED || $variables['comment_mode'] == COMMENT_HIDDEN) {
if ($variables['comment_mode'] == CommentItemInterface::CLOSED || $variables['comment_mode'] == CommentItemInterface::HIDDEN) {
$icon_status_class = 'closed';
$variables['icon_title'] = t('Closed topic');
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\forum\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\simpletest\WebTestBase;
/**
......@@ -75,7 +76,7 @@ function testForumUninstallWithField() {
// We want to test the handling of removing the forum comment field, so we
// ensure there is at least one other comment field attached to a node type
// so that comment_entity_load() runs for nodes.
\Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'another_comment_field', COMMENT_OPEN);
\Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'another_comment_field', CommentItemInterface::OPEN);
$this->drupalGet('node/' . $node->nid->value);
$this->assertResponse(200);
......
......@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Tests that comment count display toggles properly on comment status of node
*
......@@ -89,9 +91,9 @@ function testSearchCommentCountToggle() {
$this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Open');
// Test comment count display for nodes with comment status set to Closed
$this->searchable_nodes['0 comments']->set('comment', COMMENT_CLOSED);
$this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::CLOSED);
$this->searchable_nodes['0 comments']->save();
$this->searchable_nodes['1 comment']->set('comment', COMMENT_CLOSED);
$this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::CLOSED);
$this->searchable_nodes['1 comment']->save();
$this->drupalPostForm('', $edit, t('Search'));
......@@ -99,9 +101,9 @@ function testSearchCommentCountToggle() {
$this->assertText(t('1 comment'), 'Non-empty comment count displays for nodes with comment status set to Closed');
// Test comment count display for nodes with comment status set to Hidden
$this->searchable_nodes['0 comments']->set('comment', COMMENT_HIDDEN);
$this->searchable_nodes['0 comments']->set('comment', CommentItemInterface::HIDDEN);
$this->searchable_nodes['0 comments']->save();
$this->searchable_nodes['1 comment']->set('comment', COMMENT_HIDDEN);
$this->searchable_nodes['1 comment']->set('comment', CommentItemInterface::HIDDEN);
$this->searchable_nodes['1 comment']->save();
$this->drupalPostForm('', $edit, t('Search'));
......
......@@ -7,6 +7,7 @@
namespace Drupal\search\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\field\Field;
/**
......@@ -114,7 +115,7 @@ function testSearchResultsComment() {
// Hide comments.
$this->drupalLogin($this->admin_user);
$node->set('comment', COMMENT_HIDDEN);
$node->set('comment', CommentItemInterface::HIDDEN);
$node->save();
// Invoke search index update.
......
......@@ -7,6 +7,8 @@
namespace Drupal\search\Tests;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
/**
* Indexes content and tests ranking factors.
*/
......@@ -56,7 +58,7 @@ public function testRankings() {
$settings = array(
'type' => 'page',
'comment' => array(array(
'status' => COMMENT_HIDDEN,
'status' => CommentItemInterface::HIDDEN,
)),
'title' => 'Drupal rocks',
'body' => array(array('value' => "Drupal's search rocks")),
......@@ -75,7 +77,7 @@ public function testRankings() {
$settings['created'] = REQUEST_TIME + 3600;
break;
case 'comments':
$settings['comment'][0]['status'] = COMMENT_OPEN;
$settings['comment'][0]['status'] = CommentItemInterface::OPEN;
break;
}
}
......
......@@ -236,7 +236,7 @@ function drupalGetNodeByTitle($title, $reset = FALSE) {
* );
* @endcode
* - title: Random string.
* - comment: COMMENT_OPEN.
* - comment: CommentItemInterface::OPEN.
* - changed: REQUEST_TIME.
* - promote: NODE_NOT_PROMOTED.
* - log: Empty string.
......
......@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Entity;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Database\Database;
......@@ -133,7 +134,7 @@ public function testBlockHooks() {
public function testCommentHooks() {
$account = $this->createUser();
$this->enableModules(array('entity', 'filter'));
$this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment', COMMENT_OPEN);
$this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment', CommentItemInterface::OPEN);
$node = entity_create('node', array(
'uid' => $account->id(),
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\comment\CommentInterface;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\simpletest\WebTestBase;
/**
......@@ -101,7 +102,7 @@ function setUp() {