Unverified Commit fc46c7f3 authored by alexpott's avatar alexpott
Browse files

Issue #3092606 by andypost, Wim Leers, Berdir, longwave: Remove comment.module BC layers

parent 46bd90dc
......@@ -28,36 +28,6 @@
use Drupal\user\RoleInterface;
use Drupal\user\UserInterface;
/**
* Anonymous posters cannot enter their contact information.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\comment\CommentInterface::ANONYMOUS_MAYNOT_CONTACT instead.
*
* @see https://www.drupal.org/node/2831620
*/
const COMMENT_ANONYMOUS_MAYNOT_CONTACT = 0;
/**
* Anonymous posters may leave their contact information.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\comment\CommentInterface::ANONYMOUS_MAY_CONTACT instead.
*
* @see https://www.drupal.org/node/2831620
*/
const COMMENT_ANONYMOUS_MAY_CONTACT = 1;
/**
* Anonymous posters are required to leave their contact information.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0.
* Use \Drupal\comment\CommentInterface::ANONYMOUS_MUST_CONTACT instead.
*
* @see https://www.drupal.org/node/2831620
*/
const COMMENT_ANONYMOUS_MUST_CONTACT = 2;
/**
* The time cutoff for comments marked as read for entity types other node.
*
......@@ -259,63 +229,6 @@ function comment_node_view_alter(array &$build, EntityInterface $node, EntityVie
}
}
/**
* Generates an array for rendering a comment.
*
* @param \Drupal\comment\CommentInterface $comment
* The comment object.
* @param string $view_mode
* (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
* 'full'.
* @param string $langcode
* (optional) A language code to use for rendering. Defaults to the global
* content language of the current request.
*
* @return array
* An array as expected by \Drupal\Core\Render\RendererInterface::render().
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal::entityTypeManager()->getViewBuilder('comment')->view().
*
* @see https://www.drupal.org/node/3033656
*/
function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode = NULL) {
@trigger_error("comment_view() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('comment')->view() instead. See https://www.drupal.org/node/3033656", E_USER_DEPRECATED);
return \Drupal::entityTypeManager()
->getViewBuilder('comment')
->view($comment, $view_mode, $langcode);
}
/**
* Constructs render array from an array of loaded comments.
*
* @param \Drupal\comment\CommentInterface[] $comments
* An array of comments as returned by entity_load_multiple().
* @param string $view_mode
* (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to
* 'full'.
* @param string $langcode
* (optional) A string indicating the language field values are to be shown
* in. If no language is provided the current content language is used.
* Defaults to NULL.
*
* @return array
* An array in the format expected by
* \Drupal\Core\Render\RendererInterface::render().
*
* @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0.
* Use \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple().
*
* @see https://www.drupal.org/node/3033656
* @see \Drupal\Core\Render\RendererInterface::render()
*/
function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) {
@trigger_error("comment_view_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple() instead. See https://www.drupal.org/node/3033656", E_USER_DEPRECATED);
return \Drupal::entityTypeManager()
->getViewBuilder('comment')
->viewMultiple($comments, $view_mode, $langcode);
}
/**
* Implements hook_form_FORM_ID_alter() for field_ui_field_storage_add_form.
*/
......
......@@ -22,18 +22,6 @@ field.widget.settings.comment_default:
type: mapping
label: 'Comment display format settings'
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
# @see https://www.drupal.org/node/2919303
action.configuration.comment_publish_action:
type: action_configuration_default
label: 'Publish comment configuration'
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
# @see https://www.drupal.org/node/2919303
action.configuration.comment_save_action:
type: action_configuration_default
label: 'Save comment configuration'
action.configuration.comment_unpublish_by_keyword_action:
type: mapping
label: 'Unpublish comment containing keyword(s) configuration'
......@@ -45,18 +33,6 @@ action.configuration.comment_unpublish_by_keyword_action:
type: string
label: 'Keyword'
# @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.0.
# @see https://www.drupal.org/node/2919303
action.configuration.comment_unpublish_action:
type: action_configuration_default
label: 'Unpublish comment configuration'
# @deprecated in Drupal 8.6.x, to be removed before Drupal 9.0.0.
# @see https://www.drupal.org/node/2934349
action.configuration.comment_delete_action:
type: action_configuration_default
label: 'Delete comment configuration'
comment.type.*:
type: config_entity
label: 'Comment type settings'
......
......@@ -208,20 +208,6 @@ public function getCreatedTime();
*/
public function setCreatedTime($created);
/**
* Returns the comment's status.
*
* @return int|string|bool
* Either TRUE, '1', or CommentInterface::PUBLISHED(1) if the comment is
* published, or FALSE, '0', or CommentInterface::NOT_PUBLISHED(0) if the
* comment is not published.
*
* @deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead.
* @see https://www.drupal.org/node/2830201
*/
public function getStatus();
/**
* Returns the alphadecimal representation of the comment's place in a thread.
*
......
......@@ -479,14 +479,6 @@ public function setCreatedTime($created) {
return $this;
}
/**
* {@inheritdoc}
*/
public function getStatus() {
@trigger_error(__NAMESPACE__ . '\Comment::getStatus() is deprecated in drupal:8.3.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\EntityPublishedInterface::isPublished() instead. See https://www.drupal.org/node/2830201', E_USER_DEPRECATED);
return $this->get('status')->value;
}
/**
* {@inheritdoc}
*/
......
<?php
namespace Drupal\comment\Plugin\Action;
use Drupal\Core\Action\Plugin\Action\DeleteAction;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
/**
* Deletes a comment.
*
* @deprecated in drupal:8.6.0 and is removed from drupal:9.0.0.
* Use \Drupal\Core\Action\Plugin\Action\DeleteAction instead.
*
* @see \Drupal\Core\Action\Plugin\Action\DeleteAction
* @see https://www.drupal.org/node/2934349
*
* @Action(
* id = "comment_delete_action",
* label = @Translation("Delete comment")
* )
*/
class DeleteComment extends DeleteAction {
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, PrivateTempStoreFactory $temp_store_factory, AccountInterface $current_user) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $temp_store_factory, $current_user);
@trigger_error(__NAMESPACE__ . '\DeleteComment is deprecated in Drupal 8.6.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\DeleteAction instead. See https://www.drupal.org/node/2934349.', E_USER_DEPRECATED);
}
}
<?php
namespace Drupal\comment\Plugin\Action;
use Drupal\Core\Action\Plugin\Action\PublishAction;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Publishes a comment.
*
* @deprecated in drupal:8.5.0 and is removed from drupal:9.0.0.
* Use \Drupal\Core\Action\Plugin\Action\PublishAction instead.
*
* @see \Drupal\Core\Action\Plugin\Action\PublishAction
* @see https://www.drupal.org/node/2919303
*
* @Action(
* id = "comment_publish_action",
* label = @Translation("Publish comment"),
* type = "comment"
* )
*/
class PublishComment extends PublishAction {
/**
* {@inheritdoc}
*/
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
@trigger_error(__NAMESPACE__ . '\PublishComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\PublishAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
}
}
<?php
namespace Drupal\comment\Plugin\Action;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Action\Plugin\Action\SaveAction;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Saves a comment.
*
* @deprecated in drupal:8.5.0 and is removed from drupal:9.0.0.
* Use \Drupal\Core\Action\Plugin\Action\SaveAction instead.
*
* @see \Drupal\Core\Action\Plugin\Action\SaveAction
* @see https://www.drupal.org/node/2919303
*
* @Action(
* id = "comment_save_action",
* label = @Translation("Save comment"),
* type = "comment"
* )
*/
class SaveComment extends SaveAction {
/**
* {@inheritdoc}
*/
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, TimeInterface $time) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $time);
@trigger_error(__NAMESPACE__ . '\SaveComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\SaveAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
}
}
<?php
namespace Drupal\comment\Plugin\Action;
use Drupal\Core\Action\Plugin\Action\UnpublishAction;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Unpublishes a comment.
*
* @deprecated in drupal:8.5.0 and is removed from drupal:9.0.0.
* Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead.
*
* @see \Drupal\Core\Action\Plugin\Action\UnpublishAction
* @see https://www.drupal.org/node/2919303
*
* @Action(
* id = "comment_unpublish_action",
* label = @Translation("Unpublish comment"),
* type = "comment"
* )
*/
class UnpublishComment extends UnpublishAction {
/**
* {@inheritdoc}
*/
public function __construct($configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager);
@trigger_error(__NAMESPACE__ . '\UnpublishComment is deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0. Use \Drupal\Core\Action\Plugin\Action\UnpublishAction instead. See https://www.drupal.org/node/2919303.', E_USER_DEPRECATED);
}
}
......@@ -43,9 +43,6 @@ public function prepareRow(Row $row) {
/**
* Provides a BC layer for deprecated sources.
*
* This is a backward compatibility layer for the deprecated migrate source
* plugins d6_comment_variable and d6_comment_variable_per_comment_type.
*
* @param \Drupal\migrate\Row $row
* The row from the source to process.
*
......
<?php
namespace Drupal\comment\Plugin\migrate\source\d6;
@trigger_error('CommentVariable is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.', E_USER_DEPRECATED);
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Plugin\migrate\source\DummyQueryTrait;
/**
* @MigrateSource(
* id = "d6_comment_variable",
* source_module = "comment"
* )
*
* @deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use
* \Drupal\node\Plugin\migrate\source\d6\NodeType instead.
*/
class CommentVariable extends DrupalSqlBase {
use DummyQueryTrait;
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
return new \ArrayIterator($this->getCommentVariables());
}
/**
* {@inheritdoc}
*/
public function count($refresh = FALSE) {
return count($this->getCommentVariables());
}
/**
* Retrieves the values of the comment variables grouped by node type.
*
* @return array
*/
protected function getCommentVariables() {
$comment_prefixes = array_keys($this->commentPrefixes());
$variables = [];
$node_types = $this->select('node_type', 'nt')
->fields('nt', ['type'])
->execute()
->fetchCol();
foreach ($node_types as $node_type) {
foreach ($comment_prefixes as $prefix) {
$variables[] = $prefix . '_' . $node_type;
}
}
$return = [];
$values = $this->select('variable', 'v')
->fields('v', ['name', 'value'])
->condition('name', $variables, 'IN')
->execute()
->fetchAllKeyed();
foreach ($node_types as $node_type) {
foreach ($comment_prefixes as $prefix) {
$name = $prefix . '_' . $node_type;
if (isset($values[$name])) {
$return[$node_type][$prefix] = unserialize($values[$name]);
}
}
}
// The return key will not be used so move it inside the row. This could
// not be done sooner because otherwise empty rows would be created with
// just the node type in it.
foreach ($return as $node_type => $data) {
$return[$node_type]['node_type'] = $node_type;
$return[$node_type]['comment_type'] = empty($data['comment_subject_field']) ?
'comment_no_subject' : 'comment';
}
return $return;
}
/**
* {@inheritdoc}
*/
public function fields() {
return $this->commentPrefixes() + [
'node_type' => $this->t('The node type'),
'comment_type' => $this->t('The comment type'),
];
}
/**
* Comment related data for fields.
*/
protected function commentPrefixes() {
return [
'comment' => $this->t('Default comment setting'),
'comment_default_mode' => $this->t('Default display mode'),
'comment_default_order' => $this->t('Default display order'),
'comment_default_per_page' => $this->t('Default comments per page'),
'comment_controls' => $this->t('Comment controls'),
'comment_anonymous' => $this->t('Anonymous commenting'),
'comment_subject_field' => $this->t('Comment subject field'),
'comment_preview' => $this->t('Preview comment'),
'comment_form_location' => $this->t('Location of comment submission form'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['node_type']['type'] = 'string';
return $ids;
}
}
<?php
namespace Drupal\comment\Plugin\migrate\source\d6;
@trigger_error('CommentVariablePerCommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.', E_USER_DEPRECATED);
/**
* @MigrateSource(
* id = "d6_comment_variable_per_comment_type",
* source_module = "comment"
* )
*
* @deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use
* \Drupal\node\Plugin\migrate\source\d6\NodeType instead.
*/
class CommentVariablePerCommentType extends CommentVariable {
/**
* Retrieves the values of the comment variables grouped by comment type.
*
* @return array
*/
protected function getCommentVariables() {
$node_types = parent::getCommentVariables();
// The return key used to separate comment types with hidden subject field.
$return = [];
foreach ($node_types as $node_type => $data) {
// Only 2 comment types depending on subject field visibility.
if (!empty($data['comment_subject_field'])) {
// Default label and description should be set in migration.
$return['comment'] = [
'comment_type' => 'comment',
'label' => $this->t('Default comments'),
'description' => $this->t('Allows commenting on content'),
];
}
else {
// Provide a special comment type with hidden subject field.
$return['comment_no_subject'] = [
'comment_type' => 'comment_no_subject',
'label' => $this->t('Comments without subject field'),
'description' => $this->t('Allows commenting on content, comments without subject field'),
];
}
}
return $return;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'comment_type' => $this->t('The comment type'),
'label' => $this->t('The comment type label'),
'description' => $this->t('The comment type description'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['comment_type']['type'] = 'string';
return $ids;
}
}
<?php
namespace Drupal\comment\Plugin\migrate\source\d7;
@trigger_error('CommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d7\NodeType instead.', E_USER_DEPRECATED);
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 comment type source from database.
*
* @MigrateSource(
* id = "d7_comment_type",
* source_module = "comment"
* )
*
* @deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use
* \Drupal\node\Plugin\migrate\source\d7\NodeType instead.
*/
class CommentType extends DrupalSqlBase {
/**
* A map of D7 node types to their labels.
*
* @var string[]
*/
protected $nodeTypes = [];
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('field_config_instance', 'fci')
->distinct()
->fields('fci', ['bundle'])
->condition('fci.entity_type', 'comment');
}
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
$this->nodeTypes = $this->select('node_type', 'nt')
->fields('nt', ['type', 'name'])
->execute()
->fetchAllKeyed();
return parent::initializeIterator();
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$node_type = substr($row->getSourceProperty('bundle'), 13);
$row->setSourceProperty('node_type', $node_type);
$row->setSourceProperty('default_mode', $this->variableGet("comment_default_mode_$node_type", 1));
$row->setSourceProperty('per_page', $this->variableGet("comment_default_per_page_$node_type", 50));
$row->setSourceProperty('anonymous', $this->variableGet("comment_anonymous_$node_type", FALSE));
$row->setSourceProperty('form_location', $this->variableGet("comment_form_location_$node_type", CommentItemInterface::FORM_BELOW));
$row->setSourceProperty('preview', $this->variableGet("comment_preview_$node_type", TRUE));
$row->setSourceProperty('subject', $this->variableGet("comment_subject_field_$node_type", TRUE));
$label = $this->t('@node_type comment', [
'@node_type' => $this->nodeTypes[$node_type],
]);
$row->setSourceProperty('label', $label);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'label' => $this->t('The label of the comment type.'),
'bundle' => $this->t('Bundle ID of the comment type.'),
'node_type' => $this->t('The node type to which this comment type is attached.'),
'default_mode' => $this->t('Default comment mode.'),
'per_page' => $this->t('Number of comments visible per page.'),
'anonymous' => $this->t('Whether anonymous comments are allowed.'),
'form_location' => $this->t('Location of the comment form.'),
'preview' => $this->t('Whether previews are enabled for the comment type.'),