1

I was looking for a built-in method to urlize/slugify a string, instead of copying a strandard one found on google.

Thus I found this : http://sourcecookbook.com/en/recipes/59/call-the-slugify-urlize-function-from-doctrine , referencing to this Doctrine Class http://www.tig12.net/downloads/apidocs/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Doctrine_Inflector.class.html , with the method urlize() which is exactly what I'm looking for.

But, in my Doctrine Bundle from Symfony 2, in \vendor\doctrine\common\lib\Doctrine\Common\Util my Inflector class is pretty empty.

What happened to this urlize() method ? Do I have to recode it ?

Bonswouar
  • 1,521
  • 2
  • 17
  • 37

2 Answers2

2

There's https://github.com/Behat/Transliterator which includes the urlize function from Doctrine1

This is the part taken from Doctrine 1.2.3
Doctrine inflector has static methods for inflecting text

You could just composer require behat/transliterator
and have a HelperClass extending Behat\Transliterator.

And then be able to do: MyStringHelper::urlize("isn't that great?")

gherkins
  • 14,603
  • 6
  • 44
  • 70
1

The file you are looking at (Doctrine\Common\Util\Inflector) is supposed to be used internally by Doctrine, to convert between table names (underscore separated), property names (camelCase), and class names (CamelCase).

What you are looking for can be achieved with the sluggable doctrine extension. You can ingtegrate it easily into a symfony2 application with stof/StofDoctrineExtensionsBundle.

K. Norbert
  • 10,494
  • 5
  • 49
  • 48
  • Well, I guessed it was used internally by Doctrine, but I wanted to use it anyway so I don't duplicate any code. Actually, I don't want to add an extension just for one basic function.. So I think I'll make my own class/function ! – Bonswouar Jul 04 '13 at 11:50