You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.2 KiB

  1. <?php
  2. namespace App\Service;
  3. /*
  4. * Copyright (C) 2020 Daniel Siepmann <coding@daniel-siepmann.de>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. */
  21. use Symfony\Component\String\AbstractUnicodeString;
  22. use Symfony\Component\String\Slugger\AsciiSlugger;
  23. class Slugger extends AsciiSlugger
  24. {
  25. public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
  26. {
  27. $string .= '-' . uniqid();
  28. $slug = parent::slug($string, $separator, $locale);
  29. $slug = $slug->lower();
  30. return $slug;
  31. }
  32. }