Airship\Cabin\Bridge\Blueprint\Author::updateAuthorSlug PHP Méthode

updateAuthorSlug() public méthode

Should we update the author's slug?
public updateAuthorSlug ( integer $authorId, array $post ) : boolean
$authorId integer
$post array
Résultat boolean
    public function updateAuthorSlug(int $authorId, array $post) : bool
    {
        $slug = $this->db->cell('SELECT slug FROM hull_blog_authors WHERE authorid = ?', $authorId);
        if ($slug === $post['slug']) {
            // Don't update. It's the same.
            return false;
        }
        if ($this->db->exists('SELECT count(*) FROM hull_blog_authors WHERE slug = ?', $post['slug'])) {
            // Don't update.
            return false;
        }
        if (!empty($post['redirect_slug'])) {
            $oldUrl = \implode('/', ['blog', 'author', $slug]);
            $newUrl = \implode('/', ['blog', 'author', $post['slug']]);
            $this->db->insert('airship_custom_redirect', ['oldpath' => $oldUrl, 'newpath' => $newUrl, 'cabin' => 'Hull', 'same_cabin' => true]);
        }
        // Allow updates to go through.
        return true;
    }