手动生成教条 [英] Generating doctrine slugs manually
问题描述
/ *小心 - 这不是一个真正的工作代码! * /
$ sluggable = new DoctrineSluggable();
$ slug = $ sluggable-> generate('我自己的文本!');
echo $ slug; //我自己的文本
查找原则代码用于在这里生成一个插件: l3pp4rd / DoctrineExtensions 一>。玩这个课程可以做你想要的,但你可能需要创建自己的服务来实现一个容易的使用,你想要的。有关服务的更多详细信息,请参阅文档的服务容器部分。
I'm using sluggable behavior in my Symfony2 project, but now I would like to make many slugs for one page, based on different texts (current title, old title(s), users text from form input), and keep it in another table. And my question is - how to manually use doctrine extensions for any text? I can't find it anywhere. Perfect would be something like:
/* careful - it's not a real, working code! */
$sluggable = new DoctrineSluggable();
$slug = $sluggable->generate('My own text!');
echo $slug; // my-own-text
Find the doctrine code for generating a slug here: l3pp4rd/DoctrineExtensions. Playing around with that class could do as you desire but you will probable need to create your own service to implement an easy use as you want. See the Service Container section of the docs for more details about services.
这篇关于手动生成教条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!