Stevan Tosic
Stevan Tosic

Reputation: 7199

Symfony2 Entity method called in repository class

How can I call method from entity class in repository class. I had tried to do something like this, but no success.

class ProfileConnectionsListRepository extends EntityRepository
{
       public function connectionUserNames($userId)
       {
           $connections = $this->_em
               ->findOneBy(array('user1Id' => $userId))
               ->getUser2Id();
       }
}

so if this is invalid can do something like that on doctrine way without using raw queries.

Upvotes: 0

Views: 50

Answers (1)

Tomas Votruba
Tomas Votruba

Reputation: 24280

You might need to get repository first.

$connections = $this->_em
   ->getRepository(UserEntity::class)
   ->findOneBy(array('user1Id' => $userId))
   ->getUser2Id();

Upvotes: 2

Related Questions