Bonswouar
Bonswouar

Reputation: 1590

urlize() in Doctrine_Inflector Class in Doctrine 2 / Symfony 2?

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 ?

Upvotes: 1

Views: 2161

Answers (2)

gherkins
gherkins

Reputation: 14983

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?")

Upvotes: 2

K. Norbert
K. Norbert

Reputation: 10684

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.

Upvotes: 1

Related Questions