Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommentsHistoryBlock.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Block\Block;
10 
14 class CommentsHistoryBlock extends Block
15 {
21  protected $commentHistory = '.note-list-item';
22 
28  protected $commentHistoryDate = '.note-list-date';
29 
35  protected $commentHistoryTime = '.note-list-time';
36 
42  protected $commentHistoryStatus = '.note-list-status';
43 
49  protected $commentHistoryNotifiedStatus = '.note-list-customer';
50 
56  protected $comment = '.note-list-comment';
57 
63  public function getComments()
64  {
65  $result = [];
66  $elements = $this->_rootElement->getElements($this->commentHistory);
67  foreach ($elements as $key => $item) {
68  $result[$key] = [
69  'date' => $item->find($this->commentHistoryDate)->getText(),
70  'time' => $item->find($this->commentHistoryTime)->getText(),
71  'status' => $item->find($this->commentHistoryStatus)->getText(),
72  'is_customer_notified' => $item->find($this->commentHistoryNotifiedStatus)->getText(),
73  'comment' => '',
74  ];
75  if ($item->find($this->comment)->isVisible()) {
76  $result[$key]['comment'] = $item->find($this->comment)->getText();
77  }
78  }
79 
80  return $result;
81  }
82 
88  public function getLatestComment()
89  {
90  $comments = $this->getComments();
91  return current($comments);
92  }
93 }