helperData = $helperData; $this->dateTime = $dateTime; parent::__construct($context); $this->postTable = $this->getTable('mageplaza_blog_post'); } /** * @inheritdoc */ protected function _construct() { $this->_init('mageplaza_blog_author', 'user_id'); } /** * @inheritdoc * @throws LocalizedException */ protected function _beforeSave(AbstractModel $object) { $object->setUrlKey( $this->helperData->generateUrlKey($this, $object, $object->getUrlKey() ?: $object->getName()) ); if (!$object->isObjectNew()) { $timeStamp = $this->dateTime->gmtDate(); $object->setUpdatedAt($timeStamp); } return $this; } /** * @param \Mageplaza\Blog\Model\Author $author * * @return array */ public function getPostIds(\Mageplaza\Blog\Model\Author $author) { $adapter = $this->getConnection(); $select = $adapter->select()->from( $this->postTable, 'post_id' ) ->where( 'author_id = ?', (int)$author->getId() ); return $adapter->fetchCol($select); } }