我正在寻找一种内置的方法来urlize/slugify字符串,而不是复制在google上找到的标准字符串。
因此,我找到了这个:http://sourcecookbook.com/en/recipes/59/call-the-slugify-urlize-function-from-doctrine,引用了这个Doctrine类http://www.tig12.net/downloads/apidocs/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Doctrine_Inflector.class.html,方法是urlize(),这正是我要找的。
但是,在我的Symfony 2中的Doctrine Bundle中,在\vendor\doctrine\common\lib\Doctrine\Common\Util中我的Inflector类是相当空的。
这个urlize()方法出了什么问题?我需要重新编码吗?
发布于 2014-12-01 17:28:29
包含来自Doctrine1的urlize函数的https://github.com/Behat/Transliterator
这是取自1.2.3原则的部分
Doctrine具有静态的文本变形方法
你可以直接用composer require behat/transliterator
并有一个扩展Behat\Transliterator的HelperClass。
然后就能做到:MyStringHelper::urlize("isn't that great?")
发布于 2013-07-04 19:14:51
您正在查看的文件( Doctrine \Common\Util\Inflector)应该由Doctrine在内部使用,用于在表名(下划线分隔)、属性名(camelCase)和类名(CamelCase)之间进行转换。
您正在寻找的东西可以通过sluggable原理扩展来实现。您可以使用stof/StofDoctrineExtensionsBundle轻松地将其集成到symfony2应用程序中。
https://stackoverflow.com/questions/17467910
复制相似问题