Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommentsHistoryUpdater.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Signifyd\Model;
7 
10 use Magento\Sales\Model\Order\Status\HistoryFactory;
12 
17 {
21  private $historyFactory;
22 
26  private $historyRepository;
27 
34  public function __construct(
35  HistoryFactory $historyFactory,
36  OrderStatusHistoryRepositoryInterface $historyRepository
37  ) {
38  $this->historyFactory = $historyFactory;
39  $this->historyRepository = $historyRepository;
40  }
41 
51  public function addComment(CaseInterface $case, Phrase $message, $status = '')
52  {
53  if (!$message->getText()) {
54  return;
55  }
56 
58  $history = $this->historyFactory->create();
59  $history->setParentId($case->getOrderId())
60  ->setComment($message)
61  ->setEntityName('order')
62  ->setStatus($status);
63  $this->historyRepository->save($history);
64  }
65 }
$case
$message
$status
Definition: order_status.php:8
__construct(HistoryFactory $historyFactory, OrderStatusHistoryRepositoryInterface $historyRepository)