diff --git a/vendor/magento/module-purchase-order/Model/CommentManagement.php b/vendor/magento/module-purchase-order/Model/CommentManagement.php index d5cbb7b9fe8e..228d9216b3eb 100644 --- a/vendor/magento/module-purchase-order/Model/CommentManagement.php +++ b/vendor/magento/module-purchase-order/Model/CommentManagement.php @@ -6,6 +6,7 @@ namespace Magento\PurchaseOrder\Model; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\LocalizedException; use Magento\PurchaseOrder\Api\Data\CommentInterface; use Magento\PurchaseOrder\Api\Data\CommentInterfaceFactory; @@ -25,7 +26,7 @@ class CommentManagement private $commentCollectionFactory; /** - * @var CommentFactory + * @var CommentInterfaceFactory */ private $commentFactory; @@ -34,19 +35,28 @@ class CommentManagement */ private $notifier; + /** + * @var CommentRepositoryInterface + */ + private $commentRepository; + /** * @param CommentInterfaceFactory $commentFactory * @param CommentCollectionFactory $commentCollectionFactory * @param NotifierInterface $notifier + * @param CommentRepositoryInterface|null $commentRepository */ public function __construct( CommentInterfaceFactory $commentFactory, CommentCollectionFactory $commentCollectionFactory, - NotifierInterface $notifier + NotifierInterface $notifier, + ?CommentRepositoryInterface $commentRepository = null ) { $this->commentFactory = $commentFactory; $this->commentCollectionFactory = $commentCollectionFactory; $this->notifier = $notifier; + $this->commentRepository = $commentRepository ?: + ObjectManager::getInstance()->get(CommentRepositoryInterface::class); } /** @@ -71,6 +81,7 @@ public function addComment( $comment->save(); + $comment = $this->commentRepository->get($comment->getEntityId()); $this->notifier->notifyOnAction($comment->getEntityId(), CommentAdded::class); return $comment;