topicFactory = $topicFactory; $this->coreRegistry = $coreRegistry; parent::__construct($context); } /** * @param bool $register * * @return bool|\Mageplaza\Blog\Model\Topic */ protected function initTopic($register = false) { $topicId = (int)$this->getRequest()->getParam('id'); /** @var \Mageplaza\Blog\Model\Topic $topic */ $topic = $this->topicFactory->create(); if ($topicId) { $topic->load($topicId); if (!$topic->getId()) { $this->messageManager->addErrorMessage(__('This topic no longer exists.')); return false; } } if ($register) { $this->coreRegistry->register('mageplaza_blog_topic', $topic); } return $topic; } }