_url = $url; } /** * Initialize user model * * @return void */ protected function _construct() { $this->_init('Magefan\Blog\Model\ResourceModel\Author'); } /** * Retrieve author name (used in identifier generation) * @return string | null */ public function getTitle() { return $this->getName(); } /** * Retrieve author identifier * @return string | null */ public function getIdentifier() { return preg_replace( "/[^A-Za-z0-9\-]/", '', strtolower($this->getName('-')) ); } /** * Check if author identifier exist * return author id if author exists * * @param string $identifier * @return int */ public function checkIdentifier($identifier) { $authors = $this->getCollection(); foreach($authors as $author) { if ($author->getIdentifier() == $identifier) { return $author->getId(); } } return 0; } /** * Retrieve author url route path * @return string */ public function getUrl() { return $this->_url->getUrlPath($this, URL::CONTROLLER_AUTHOR); } /** * Retrieve author url * @return string */ public function getAuthorUrl() { return $this->_url->getUrl($this, URL::CONTROLLER_AUTHOR); } /** * Retrieve author name * * @param string $separator * @return string */ public function getName($separator = ' ') { return $this->getFirstname() . $separator . $this->getLastname(); } }