Airship\Engine\Bolt\Slug::makeGenericSlug PHP Method

makeGenericSlug() protected method

Make a generic slug for most tables
protected makeGenericSlug ( string $title, string $table, string $column = 'slug' ) : string
$title string What are we basing the URL off of?
$table string Which table to check for duplicates?
$column string Which column to check for duplicates?
return string
    protected function makeGenericSlug(string $title, string $table, string $column = 'slug') : string
    {
        if (IDE_HACKS) {
            $this->db = \Airship\get_database();
        }
        $query = 'SELECT count(*) FROM ' . $this->db->escapeIdentifier($table) . ' WHERE ' . $this->db->escapeIdentifier($column) . ' = ?';
        $slug = $base_slug = \Airship\slugFromTitle($title);
        $i = 1;
        while ($this->db->cell($query, $slug) > 0) {
            $slug = $base_slug . '-' . ++$i;
        }
        return $slug;
    }