authorFactory = $authorFactory; $this->coreRegistry = $coreRegistry; parent::__construct($context); } /** * @param bool $register * * @return bool|\Mageplaza\Blog\Model\Author */ public function initAuthor($register = false) { $authorId = (int)$this->getRequest()->getParam('id'); /** @var \Mageplaza\Blog\Model\Author $author */ $author = $this->authorFactory->create(); if ($authorId) { $author->load($authorId); if (!$author->getId()) { $this->messageManager->addErrorMessage(__('This author no longer exists.')); return false; } } if ($register) { $this->coreRegistry->register('mageplaza_blog_author', $author); } return $author; } }