postHistoryFactory = $postHistoryFactory; $this->postFactory = $postFactory; $this->coreRegistry = $coreRegistry; $this->date = $date; parent::__construct($context); } /** * @param bool $register * * @return bool|PostHistory */ protected function initPostHistory($register = false) { $historyId = (int)$this->getRequest()->getParam('id'); /** @var \Mageplaza\Blog\Model\Post $post */ $history = $this->postHistoryFactory->create(); if ($historyId) { $history->load($historyId); if (!$history->getId()) { $this->messageManager->addErrorMessage(__('This History no longer exists.')); return false; } } if ($register) { $this->coreRegistry->register('mageplaza_blog_post_history', $history); } return $history; } }