Commit c4550b7b authored by alexpott's avatar alexpott
Browse files

Issue #2321599 by Temoor, rpayanm, subhojit777, vineeth@nair, LinL, pcambra:...

Issue #2321599 by Temoor, rpayanm, subhojit777, vineeth@nair, LinL, pcambra: Replace all instances of comment_load(), entity_load('comment') and entity_load_multiple('comment') with static method calls
parent c127131f
......@@ -34,6 +34,11 @@ class Rss extends RssPluginBase {
*/
protected $base_field = 'cid';
/**
* @var \Drupal\comment\CommentInterface[]
*/
protected $comments;
/**
* {@inheritdoc}
*/
......@@ -46,7 +51,7 @@ public function preRender($result) {
$cids[] = $row->cid;
}
$this->comments = entity_load_multiple('comment', $cids);
$this->comments = $this->entityManager->getStorage('comment')->loadMultiple($cids);
foreach ($this->comments as $comment) {
$comment->depth = count(explode('.', $comment->getThread())) - 1;
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\field\Entity\FieldConfig;
......@@ -164,7 +165,7 @@ function postComment(EntityInterface $entity, $comment, $subject = '', $contact
}
if (isset($match[1])) {
return entity_load('comment', $match[1]);
return Comment::load($match[1]);
}
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests\Views;
use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment;
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestBase;
......@@ -103,7 +104,7 @@ protected function setUp() {
}
// Store all the nodes just created to access their properties on the tests.
$this->commentsCreated = entity_load_multiple('comment');
$this->commentsCreated = Comment::loadMultiple();
// Sort created comments in descending order.
ksort($this->commentsCreated, SORT_NUMERIC);
......
......@@ -76,8 +76,10 @@ protected function setUp() {
* Tests the Drupal 6 to Drupal 8 comment migration.
*/
public function testComments() {
/** @var \Drupal\Core\Entity\EntityStorageInterface $comment_storage */
$comment_storage = $this->container->get('entity.manager')->getStorage('comment');
/** @var \Drupal\comment\CommentInterface $comment */
$comment = entity_load('comment', 1);
$comment = $comment_storage->load(1);
$this->assertIdentical('The first comment.', $comment->getSubject());
$this->assertIdentical('The first comment body.', $comment->comment_body->value);
$this->assertIdentical('filtered_html', $comment->comment_body->format);
......@@ -87,11 +89,11 @@ public function testComments() {
$this->assertIdentical('en', $comment->language()->getId());
$this->assertIdentical('comment_no_subject', $comment->getTypeId());
$comment = entity_load('comment', 2);
$comment = $comment_storage->load(2);
$this->assertIdentical('The response to the second comment.', $comment->subject->value);
$this->assertIdentical('3', $comment->pid->target_id);
$comment = entity_load('comment', 3);
$comment = $comment_storage->load(3);
$this->assertIdentical('The second comment.', $comment->subject->value);
$this->assertIdentical('0', $comment->pid->target_id);
}
......
......@@ -7,6 +7,7 @@
namespace Drupal\migrate_drupal\Tests\d6;
use Drupal\comment\Entity\CommentType;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
......@@ -41,9 +42,9 @@ protected function setUp() {
* Tests the Drupal 6 to Drupal 8 comment type migration.
*/
public function testCommentType() {
$comment_type = entity_load('comment_type', 'comment');
$comment_type = CommentType::load('comment');
$this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
$comment_type = entity_load('comment_type', 'comment_no_subject');
$comment_type = CommentType::load('comment_no_subject');
$this->assertIdentical('node', $comment_type->getTargetEntityTypeId());
}
......
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