commentFactory = $commentFactory; $this->coreRegistry = $coreRegistry; parent::__construct($context); } /** * @param bool $register * * @return bool|\Mageplaza\Blog\Model\Comment */ protected function initComment($register = false) { $cmtId = $this->getRequest()->getParam("id"); /** @var \Mageplaza\Blog\Model\Post $post */ $comment = $this->commentFactory->create(); if ($cmtId) { $comment->load($cmtId); if (!$comment->getId()) { $this->messageManager->addErrorMessage(__('This comment no longer exists.')); return false; } } if ($register) { $this->coreRegistry->register('mageplaza_blog_comment', $comment); } return $comment; } }