我目前正在使用带有 FOSRestBundle 的 Symfony2 开发 RESTful API。
我喜欢 Mongodb,所以我已经实现了,这是我的用户控制器的片段。
/**
* @return View view instance
* @View()
*/
public function allAction() {
$users = $this->get('doctrine_mongodb')
->getRepository('FantasytdUserBundle:User')
->findByUsername('Elvar');
return $users;
}
所以我在数据库中找到了一个用户,这会产生一个结果。如果使用 mysql 数据库完成此操作,则此代码段将起作用。但是对于 mongodb,get 方法会返回一个 Cursor 对象,当它返回时,你会得到类似这样的东西。
[{"message":"[Semantical Error] Annotation @Secure is not allowed to be declared on class JMS\\SecurityExtraBundle\\Annotation\\Secure. You may only use this annotation on these code elements: METHOD.","class":"Doctrine\\Common\\Annotations\\AnnotationException","trace":[{"namespace":"","short_class":"","class":"","type":"","function":"","file":"\/Users\/Elvar\/Projects\/fantasytd\/backend\/vendor\/doctrine\/common\/lib\/Doctrine\/Common\/Annotations\/AnnotationException.php","line":52,"args":[]},
它还在继续。
我应该如何处理这些光标对象?