原文作者:FriendsOfSymfony
授权许可:创作共用协议
翻译人员:FireHare
校对人员:
适用版本:FOSCommentBundle 2.0.5
文章状态:草译阶段
FOSComment bundle allows a developer to implement RawCommentInterface, which will tell the bundle that your comments are to be parsed for a markup language.
FOSComment功能包允许开发者实现 RawCommentInterface接口,该接口告诉功能包您的评论将作为标识语言解析。
You will also need to configure a rawBody field in your database to store the parsed comments.
您也需要在您的数据库中配置 rawBody 字段,用来保存被解析后的评论。
use FOS\CommentBundle\Model\RawCommentInterface; class Comment extends BaseComment implements RawCommentInterface /** * @ORM\Column(name="rawBody", type="text", nullable=true) * @var string */ protected $rawBody; ... also add getter and setter as defined in the RawCommentInterface ...
When a comment is added, it is parsed and setRawBody() is called with the raw version of the comment which is then stored in the database and shown when the comment is later rendered.
当添加一个评论时,它被解析,然后调用 setRawBody()方法,并且与原始版本的评论一起保存在数据库中,然后在该评论被渲染时显示。
Any markup language is supported, all you need is a bridging class that implements Markup\ParserInterface
and returns the parsed result of a comment in raw html to be displayed on the page.
支持任何标识语言,您所需要做的就是一个桥接类,实现Markup\ParserInterface
,然后返回解析结果,并在页面上显示该评论的原始HTML。
To set up your own custom markup parser, you are required to define a service that implements the above interface, and to tell FOSCommentBundle about it,adjust the configuration accordingly
要安装您自己定制的标识解析器,您需要定义一个实现了上述接口的服务,并告诉FOSCommentBundle功能包相应地调整配置。
# app/config/config.yml fos_comment: service: markup: your_markup_service
Allow your users to post safe HTML with ExerciseHtmlPurifierBundle
Enable the sundown pecl extension to parse comments for markdown
Implement a BBCode parser to let your users post comments with BBCode