0

我需要在我的数据库和当前用户中获取一些数据,所以我使用实体管理器和security.context我的服务

我有这个错误:

致命错误:在第 84 行的 path/to/file 中的非对象上调用成员函数 getRepository()

服务.yml:

services:
ns_messagerie.letterboxcore:
    class: ns\MessagerieBundle\LetterBoxCore\LetterBoxCore
    arguments: [@security.context, @doctrine.orm.entity_manager]

依赖注入:

class nsMessagerieExtension extends Extension
{
    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');
    }
}

我的服务:

class LetterBoxCore {

    protected $securityContext;
    protected $em;

    public function __construct( $securityContext,  $entityManager) {
        $this->securityContext = $securityContext;
        $this->em = $entityManager;
    }

public function countNbNotRead(Utilisateur $user = null, Discussion $discussions) {
//...
}

public function getAllDiscussion(Utilisateur $user = null, $all = null) { 
// line 84:
$list = $em->getRepository('nsMessagerieBundle:ParticipantMessagerie')
                              ->findBy(array('participant' => $user,
                                             'supprimer' => $all
                                      )
                                 );

}

public function getBAL(Utilisateur $user = null) {
// Call the method countNbNotRead and GetAllDiscussion
}
4

0 回答 0