Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace PerFerLibs\UtilsBundle\Sluggable;
- class Sluggable// extends \PerFerLibs\UtilsBundle\PerFerLibsUtilsBundle
- {
- /**
- * Transliteration callback for slugs
- *
- * @var array
- */
- private $transliterator = array('PerFerLibs\UtilsBundle\Sluggable\Util\Urlizer', 'transliterate');
- /**
- * Set the transliteration callable method
- * to transliterate slugs
- *
- * @param mixed $callable
- */
- public function setTransliterator($callable)
- {
- if (!is_callable($callable)) {
- throw new \Exception('Invalid transliterator callable parameter given');
- }
- $this->transliterator = $callable;
- }
- /**
- * Creates a slug for the recieved array of fields
- *
- * @param array $fieldsToSlug
- * @param char $separator
- * @return string
- */
- public static function slugize($fieldsToSlug = array(), $separator = '-')
- {
- $slug = '';
- foreach ($fieldsToSlug as $fieldToSlug) {
- $slug .= $fieldToSlug . ' ';
- }
- if(strlen(trim($slug))) {
- $slug = call_user_func_array($this->transliterator, array($slug, $separator));
- return $slug;
- }
- else
- {
- throw new \Exception('Empty slug supplied');
- }
- }
- }
- Error
- 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
- 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