Guest User

Untitled

a guest
Nov 24th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. namespace PerFerLibs\UtilsBundle\Sluggable;
  4.  
  5. class Sluggable// extends \PerFerLibs\UtilsBundle\PerFerLibsUtilsBundle
  6. {
  7. /**
  8. * Transliteration callback for slugs
  9. *
  10. * @var array
  11. */
  12. private $transliterator = array('PerFerLibs\UtilsBundle\Sluggable\Util\Urlizer', 'transliterate');
  13.  
  14. /**
  15. * Set the transliteration callable method
  16. * to transliterate slugs
  17. *
  18. * @param mixed $callable
  19. */
  20. public function setTransliterator($callable)
  21. {
  22. if (!is_callable($callable)) {
  23. throw new \Exception('Invalid transliterator callable parameter given');
  24. }
  25. $this->transliterator = $callable;
  26. }
  27.  
  28. /**
  29. * Creates a slug for the recieved array of fields
  30. *
  31. * @param array $fieldsToSlug
  32. * @param char $separator
  33. * @return string
  34. */
  35. public static function slugize($fieldsToSlug = array(), $separator = '-')
  36. {
  37. $slug = '';
  38. foreach ($fieldsToSlug as $fieldToSlug) {
  39. $slug .= $fieldToSlug . ' ';
  40. }
  41.  
  42. if(strlen(trim($slug))) {
  43. $slug = call_user_func_array($this->transliterator, array($slug, $separator));
  44. return $slug;
  45. }
  46. else
  47. {
  48. throw new \Exception('Empty slug supplied');
  49. }
  50. }
  51. }
  52.  
  53. Error
  54.  
  55.  
  56. PHP Fatal error: Using $this when not in object context in /home/sibok/public_html/gofree/lib/PerFerLibs/UtilsBundle/Sluggable/Sluggable.php on line 43
  57.  
  58. Fatal error: Using $this when not in object context in /home/sibok/public_html/gofree/lib/PerFerLibs/UtilsBundle/Sluggable/Sluggable.php on line 43
Add Comment
Please, Sign In to add comment