Skip to content

Commit

Permalink
Fix TaggableTrait utf8_slug test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
darron1217 committed Jan 16, 2018
1 parent 3fd7f0a commit 94e4570
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
21 changes: 0 additions & 21 deletions Modules/Core/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,3 @@ function asgard_editor($fieldName, $labelName, $content)
return view('core::components.textarea-wrapper', compact('fieldName', 'labelName', 'content'));
}
}

if (! function_exists('utf8_slug')) {
function utf8_slug($title, $separator = '-')
{
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';

$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);

// Replace @ with the word 'at'
$title = str_replace('@', $separator.'at'.$separator, $title);

// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));

// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);

return trim($title, $separator);
}
}
18 changes: 16 additions & 2 deletions Modules/Tag/Traits/TaggableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,22 @@ protected function getEntityClassName()
/**
* {@inheritdoc}
*/
protected function generateTagSlug($name)
protected function generateTagSlug($name, $separator = '-')
{
return utf8_slug($name);
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';

$name = preg_replace('!['.preg_quote($flip).']+!u', $separator, $name);

// Replace @ with the word 'at'
$name = str_replace('@', $separator.'at'.$separator, $name);

// Remove all characters that are not the separator, letters, numbers, or whitespace.
$name = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($name));

// Replace all separator characters and whitespace by a single separator
$name = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $name);

return trim($name, $separator);
}
}

0 comments on commit 94e4570

Please sign in to comment.