FOSCommentBundle功能包:设置Doctrine ORM映射
2013-07-25 12:55
330 查看
原文出处:2a-mapping_orm.md
原文作者:FriendsOfSymfony
授权许可:创作共用协议
翻译人员:FireHare
校对人员:
适用版本:FOSCommentBundle 2.0.5
文章状态:草译阶段
Step 2a: Setup Doctrine ORM mapping
The ORM implementation does not provide a concrete Comment class for your use,you must create one. This can be done by extending the abstract entities provided by the bundle and creating the appropriate mappings.
ORM实现并不提供为您所用的具体评论类,您必须要创建一个。您可以通过功能包提供扩展抽象实体类并创建适当的映射。
For example:
例如:
Configure your application(配置您的应用程序)
或者您喜爱XML:
Back to the main step(返回主步骤)
Step 2: Create your Comment and Thread classes.
第2步:创建您的评论类和线索类。
原文作者:FriendsOfSymfony
授权许可:创作共用协议
翻译人员:FireHare
校对人员:
适用版本:FOSCommentBundle 2.0.5
文章状态:草译阶段
Step 2a: Setup Doctrine ORM mapping
The ORM implementation does not provide a concrete Comment class for your use,you must create one. This can be done by extending the abstract entities provided by the bundle and creating the appropriate mappings.ORM实现并不提供为您所用的具体评论类,您必须要创建一个。您可以通过功能包提供扩展抽象实体类并创建适当的映射。
For example:
例如:
<?php // src/MyProject/MyBundle/Entity/Comment.php namespace MyProject\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\CommentBundle\Entity\Comment as BaseComment; /** * @ORM\Entity * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") */ class Comment extends BaseComment { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * Thread of this comment * * @var Thread * @ORM\ManyToOne(targetEntity="MyProject\MyBundle\Entity\Thread") */ protected $thread; }还有线索类:
<?php // src/MyProject/MyBundle/Entity/Thread.php namespace MyProject\MyBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\CommentBundle\Entity\Thread as BaseThread; /** * @ORM\Entity * @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") */ class Thread extends BaseThread { /** * @var string $id * * @ORM\Id * @ORM\Column(type="string") */ protected $id; }
Configure your application(配置您的应用程序)
# app/config/config.yml fos_comment: db_driver: orm class: model: comment: MyProject\MyBundle\Entity\Comment thread: MyProject\MyBundle\Entity\Thread assetic: bundles: [ "FOSCommentBundle" ]Or if you prefer XML:
或者您喜爱XML:
# app/config/config.xml <fos_comment:config db-driver="orm"> <fos_comment:class> <fos_comment:model comment="MyProject\MyBundle\Entity\Comment" thread="MyProject\MyBundle\Entity\Thread" /> </fos_comment:class> </fos_comment:config> <assetic:config> <assetic:bundle name="FOSCommentBundle" /> </assetic:config>
Back to the main step(返回主步骤)
Step 2: Create your Comment and Thread classes.第2步:创建您的评论类和线索类。
相关文章推荐
- FOSCommentBundle功能包:设置Doctrine ORM映射(投票)
- FOSCommentBundle功能包:设置Doctrine ODM映射
- FOSCommentBundle功能包:设置Doctrine ODM映射(投票)
- FOSCommentBundle功能包:基于ACL安全添加角色
- FOSCommentBundle功能包:运行测试
- FOSCommentBundle功能包:指南索引页
- FOSCommentBundle功能包:添加Symfony2内建的ACL安全
- FOSCommentBundle功能包:启用投票
- FOSCommentBundle功能包:安装解析器以便标识评论
- FOSCommentBundle功能包:与FOSUserBundle集成(投票)
- FOSCommentBundle功能包:改变样式
- FOSCommentBundle功能包:挂接到JS代码
- FOSCommentBundle功能包:与FOSUserBundle集成
- FOSCommentBundle功能包:其它添加评论到页面的方法
- FOSCommentBundle功能包:安装功能包
- FOSCommentBundle功能包:导入FOSCommentBundle路由
- FOSCommentBundle功能包:使用ExerciseHTMLPurifierBundle功能包
- FOSCommentBundle功能包:在页面中启用评论
- FOSCommentBundle功能包:使用Sundown PECL扩展
- FOSCommentBundle功能包:实现BBCode解析器