class Comment
Same name in this branch
- 9 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment
- 9 core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment
- 9 core/modules/comment/src/Plugin/migrate/source/d7/Comment.php \Drupal\comment\Plugin\migrate\source\d7\Comment
- 9 core/modules/comment/tests/modules/d6_comment_test/src/Plugin/migrate/source/d6/Comment.php \Drupal\d6_comment_test\Plugin\migrate\source\d6\Comment
Same name and namespace in other branches
- 11.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment
- 11.x core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment
- 11.x core/modules/comment/src/Plugin/migrate/source/d6/Comment.php \Drupal\comment\Plugin\migrate\source\d6\Comment
- 11.x core/modules/comment/src/Plugin/migrate/source/d7/Comment.php \Drupal\comment\Plugin\migrate\source\d7\Comment
- 10 core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment
- 10 core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment
- 10 core/modules/comment/src/Plugin/migrate/source/d6/Comment.php \Drupal\comment\Plugin\migrate\source\d6\Comment
- 10 core/modules/comment/src/Plugin/migrate/source/d7/Comment.php \Drupal\comment\Plugin\migrate\source\d7\Comment
- 8.9.x core/modules/comment/src/Entity/Comment.php \Drupal\comment\Entity\Comment
- 8.9.x core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment
- 8.9.x core/modules/comment/src/Plugin/migrate/source/d6/Comment.php \Drupal\comment\Plugin\migrate\source\d6\Comment
- 8.9.x core/modules/comment/src/Plugin/migrate/source/d7/Comment.php \Drupal\comment\Plugin\migrate\source\d7\Comment
Drupal 6 comment source from database.
For available configuration keys, refer to the parent classes.
Plugin annotation
@MigrateSource(
id = "d6_comment",
source_module = "comment"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase implements \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait extends \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\comment\Plugin\migrate\source\d6\Comment extends \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase implements \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait extends \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface extends \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase implements \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Comment
See also
\Drupal\migrate\Plugin\migrate\source\SqlBase
\Drupal\migrate\Plugin\migrate\source\SourcePluginBase
1 file declares its use of Comment
- Comment.php in core/
modules/ comment/ tests/ modules/ d6_comment_test/ src/ Plugin/ migrate/ source/ d6/ Comment.php
348 string references to 'Comment'
- ActionTest::providerSource in core/
modules/ system/ tests/ src/ Kernel/ Plugin/ migrate/ source/ ActionTest.php - AuthorNameFormatter::isApplicable in core/
modules/ comment/ src/ Plugin/ Field/ FieldFormatter/ AuthorNameFormatter.php - BigPipeRegressionTest::testCommentForm_2698811 in core/
modules/ ckeditor/ tests/ src/ FunctionalJavascript/ BigPipeRegressionTest.php - Ensure comment form works with history and big_pipe modules.
- CategoryAutocompleteTest::providerTestAutocompleteSuggestions in core/
modules/ block/ tests/ src/ Unit/ CategoryAutocompleteTest.php - Data provider for testAutocompleteSuggestions().
- CategoryAutocompleteTest::setUp in core/
modules/ block/ tests/ src/ Unit/ CategoryAutocompleteTest.php
File
-
core/
modules/ comment/ src/ Plugin/ migrate/ source/ d6/ Comment.php, line 23
Namespace
Drupal\comment\Plugin\migrate\source\d6View source
class Comment extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
$query = $this->select('comments', 'c')
->fields('c', [
'cid',
'pid',
'nid',
'uid',
'subject',
'comment',
'hostname',
'timestamp',
'status',
'thread',
'name',
'mail',
'homepage',
'format',
]);
$query->innerJoin('node', 'n', '[c].[nid] = [n].[nid]');
$query->fields('n', [
'type',
'language',
]);
$query->orderBy('c.timestamp');
return $query;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// In D6, status=0 means published, while in D8 means the opposite.
$row->setSourceProperty('status', !$row->getSourceProperty('status'));
// If node did not have a language, use site default language as a fallback.
if (!$row->getSourceProperty('language')) {
$language_default = $this->variableGet('language_default', NULL);
$language = $language_default ? $language_default->language : 'en';
$row->setSourceProperty('language', $language);
}
return parent::prepareRow($row);
}
/**
* Provides a BC layer for deprecated sources.
*
* @param \Drupal\migrate\Row $row
* The row from the source to process.
*
* @return \Drupal\migrate\Row
* The row object.
*
* @throws \Exception
* Passing a Row with a frozen source to this method will trigger an
* \Exception when attempting to set the source properties.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct
* replacement is provided.
*
* @see https://www.drupal.org/node/3221964
*/
protected function prepareComment(Row $row) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/3221964', E_USER_DEPRECATED);
if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
// Comment subject visible.
$row->setSourceProperty('field_name', 'comment');
$row->setSourceProperty('comment_type', 'comment');
}
else {
$row->setSourceProperty('field_name', 'comment_no_subject');
$row->setSourceProperty('comment_type', 'comment_no_subject');
}
// In D6, status=0 means published, while in D8 means the opposite.
// See https://www.drupal.org/node/237636.
$row->setSourceProperty('status', !$row->getSourceProperty('status'));
// If node did not have a language, use site default language as a fallback.
if (!$row->getSourceProperty('language')) {
$language_default = $this->variableGet('language_default', NULL);
$language = $language_default ? $language_default->language : 'en';
$row->setSourceProperty('language', $language);
}
return $row;
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'cid' => $this->t('Comment ID.'),
'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
'uid' => $this->t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'),
'subject' => $this->t('The comment title.'),
'comment' => $this->t('The comment body.'),
'hostname' => $this->t("The author's host name."),
'timestamp' => $this->t('The time that the comment was created, or last edited by its author, as a Unix timestamp.'),
'status' => $this->t('The published status of a comment. (0 = Published, 1 = Not Published)'),
'format' => $this->t('The {filter_formats}.format of the comment body.'),
'thread' => $this->t("The vancode representation of the comment's place in a thread."),
'name' => $this->t("The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form."),
'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
'type' => $this->t("The {node}.type to which this comment is a reply."),
'language' => $this->t("The {node}.language to which this comment is a reply. Site default language is used as a fallback if node does not have a language."),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['cid']['type'] = 'integer';
return $ids;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.