• 原文出处:6-integration_with_fosuserbundle.md

  • 原文作者:FriendsOfSymfony

  • 授权许可:创作共用协议

  • 翻译人员:FireHare

  • 校对人员:

  • 适用版本:FOSCommentBundle 2.0.5

  • 文章状态:草译阶段

Step 6: Integration with FOSUserBundle

By default, comments are made anonymously.FOSUserBundle authentication can be used to sign the comments.

缺省情况下,评论是匿名的。FOSUserBundle 认证可以用来标识评论。

A) Setup FOSUserBundle(安装FOSUserBundle)

First you have to setup FOSUserBundle. Check the instructions.

首先您需要安装 FOSUserBundle。请参阅说明。

B) Extend the Comment class(扩展评论类)

In order to add an author to a comment, the Comment class should implement the SignedCommentInterface and add a field to your mapping.

为了为评论添加作者,Comment类需要实现SignedCommentInterface接口,并添加一个字段到您的映射。

For example in the ORM:

例如,在ORM中:

<?php
// src/MyProject/MyBundle/Entity/Comment.php
namespace MyProject\MyBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\CommentBundle\Entity\Comment as BaseComment;
use FOS\CommentBundle\Model\SignedCommentInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/*** @ORM\Entity*/
class Comment extends BaseComment implements SignedCommentInterface
{// .. fields/*** Author of the comment** @ORM\ManyToOne(targetEntity="MyProject\MyBundle\Entity\User")* @var User*/protected $author;public function setAuthor(UserInterface $author){$this->author = $author;}public function getAuthor(){return $this->author;}public function getAuthorName(){if (null === $this->getAuthor()) {return 'Anonymous';}return $this->getAuthor()->getUsername();}
}

That is it!

Return to the index.

返回到指南索引页。

FOSCommentBundle功能包:与FOSUserBundle集成相关推荐

  1. FOSCommentBundle功能包:添加Symfony2内建的ACL安全

    原文出处:8-adding_symfony2s_builtin_acl_security.md 原文作者:FriendsOfSymfony 授权许可:创作共用协议 翻译人员:FireHare 校对人员 ...

  2. FOSCommentBundle功能包:改变样式

    Step 5: Style it This bundle supplies some basic CSS markup that will make it usable. It's included ...

  3. FOSCommentBundle功能包:基于ACL安全添加角色

    注意: This bundle ships with support different security setups. You can also have a look at Adding Sym ...

  4. FOSCommentBundle功能包:设置Doctrine ODM映射

    Step 2b: Setup MongoDB mapping The MongoDB implementation does not provide a concrete Comment class ...

  5. FOSCommentBundle功能包:设置Doctrine ODM映射(投票)

    原文出处:12b-mapping_mongodb.md 原文作者:FriendsOfSymfony 授权许可:创作共用协议 翻译人员:FireHare 校对人员: 适用版本:FOSCommentBun ...

  6. Ros知识【09】:功能包介绍

    前言: 一个功能包内部,包含若干个节点:每个功能包对外使用:topic.service.paremeter作为接口:其它开发人员可以使用这些接口,不必关心功能包内部细节: 一.ubuntu下安装好ro ...

  7. ROS中阶笔记(七):机器人SLAM与自主导航—SLAM功能包的使用

    ROS中阶笔记(七):机器人SLAM与自主导航-SLAM功能包的使用 文章目录 1 机器人必备条件 1.1 硬件要求 1.2 深度信息 1.2.1 激光雷达 1.2.2 kinect 1.3 里程计信 ...

  8. ROS学习(18)机器人SLAM功能包——cartographer的安装与测试

    文章目录 前言 一.安装 1.编译安装 1.1 安装依赖 1.2 初始化工作空间 1.3 下载功能包 1.4 编译安装 1.4.1 一键安装编译 1.4.2 分布安装 1.4.2.1 安装ceres- ...

  9. ROS功能包之gmapping(SLAM)

    gmapping功能包集成了Rao-Blackwellized粒子滤波算法,为开发者隐去了复杂的内部实现 gmapping功能包订阅机器人的深度信息.IMU信息和里程计信息,同时完成一些必要参数的配置 ...

最新文章

  1. 台湾前十大科技公司拼不过三星(往后一点三星都不要买啦!)
  2. 数学知识--Methods for Non-Linear Least Squares Problems(第一章)
  3. 谈一谈:抽象工厂+反射+配置文件 实现数据访问程序
  4. C++之全局函数和成员函数互相转换
  5. JZOJ 5435. 【NOIP2017提高A组集训10.30】Graph
  6. java--jdbc
  7. Centos系统普通用户开启sudo命令
  8. XML SOAP应用简介
  9. ORACLE Physical Standby 级联备库搭建
  10. papervision3D官方文档CHM格式.
  11. 大学生创业计划书PPT模板在哪免费下?经典商业计划书PPT模板大全
  12. 基于proteus的CPU控制器设计(微程序版)
  13. 量子计算机能超越光速,目前有存在超光速吗?人类是否可以超越光速?
  14. 6个让你10T硬盘立马爆掉的资源网站,再也不需要去百度上找资源了
  15. 关于项目中数据库密码加密的使用
  16. 论文解读二代GCN《Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering》
  17. 《AV1 Bitstream Decoding Process Specification》,译名:AV1比特流及解码规范-Chapter 05-语法结构-Section 01~08
  18. 2006年100首好歌
  19. MySQL数据库锁表,如何释放锁
  20. Access根据出生日期计算年龄_小技巧 | 在SPSS中根据出生日期计算年龄

热门文章

  1. LFS6.2搭建笔记(一)
  2. 主流Kubernetes发行版梳理,看完就会选了
  3. 一个新游戏的思路;大家来说说看,觉得好的话,我做成游戏
  4. Django 操作Mysql数据库 对表进行增删改查
  5. 为私有Kubernetes集群创建LoadBalancer服务
  6. AAA及Radius
  7. Jenkins +maven+tomcat自动构建部署(学习笔记三十六)
  8. 百度编辑器上传图片自定义路径,访问路径动态加载
  9. 【Linux】在虚拟机上安装CentOS7
  10. 虚拟机常用的内存查看与分析工具