本文整理匯總了PHP中Drupal\comment\Entity\Comment::loadMultiple方法的典型用法代碼示例。如果您正苦於以下問題:PHP Comment::loadMultiple方法的具體用法?PHP Comment::loadMultiple怎麽用?PHP Comment::loadMultiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\comment\Entity\Comment
的用法示例。
在下文中一共展示了Comment::loadMultiple方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
protected function setUp()
{
parent::setUp();
// Create a new content type
$content_type = $this->drupalCreateContentType();
// Add a node of the new content type.
$node_data = array('type' => $content_type->id());
$this->addDefaultCommentField('node', $content_type->id());
$this->node = $this->drupalCreateNode($node_data);
// Force a flush of the in-memory storage.
$this->container->get('views.views_data')->clear();
// Create some comments and attach them to the created node.
for ($i = 0; $i < $this->masterDisplayResults; $i++) {
/** @var \Drupal\comment\CommentInterface $comment */
$comment = Comment::create(array('status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $this->node->id()));
$comment->setOwnerId(0);
$comment->setSubject('Test comment ' . $i);
$comment->comment_body->value = 'Test body ' . $i;
$comment->comment_body->format = 'full_html';
// Ensure comments are sorted in ascending order.
$time = REQUEST_TIME + ($this->masterDisplayResults - $i);
$comment->setCreatedTime($time);
$comment->changed->value = $time;
$comment->save();
}
// Store all the nodes just created to access their properties on the tests.
$this->commentsCreated = Comment::loadMultiple();
// Sort created comments in descending order.
ksort($this->commentsCreated, SORT_NUMERIC);
}