我想实现一些服务,我做的第一件事是确定的私人$ EM为的EntityManager如下:捕致命错误:EntityManager的不能转换为字符串
<?php
namespace Users\UsersBundle\Services;
use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Usuarios\UsersBundle\Entity\User;
/**
* Class UserManager
*/
class UserManager
{
private $em;
/**
* @param EntityManager $em
*/
public function __construct(EntityManager $em)
{
$this->$em = $em;
}
}
的例子
/**
* Find all posts for a given author
*
* @param User $author
*
* @return array
*/
public function findPosts(User $author)
{
$posts = $this->$em->getRepository('BlogBundle:Post')->findBy(array(
'author' => $author
)
);
return $posts;
}
然而,当我打电话例如像一个我上面显示,我收到以下错误的任何功能:开捕致命错误:类学说的对象\ ORM \使用EntityManager非常相同的类中的功能EntityManager无法转换为字符串。
我确实导入了服务。我错过了什么?预先感谢您对我们的支持。