Answer the question
In order to leave comments, you need to log in
How to properly get data from the Repository class using Doctrine ORM without frameworks?
There is a class inherited from EntiryRepository.
The goal is to get the user's data using $email as the key and then call the getUserData() method by including the UserRepository in another class.
The problem is that when connecting the UserRepository , it also requires Required parameters '$em, $class' missing
class UserRepository extends EntityRepository
{
public function getUserData(): array
{
$user = new User();
return $this->_em->getRepository(User::class)->findOneBy($user->getEmail());
}
}
public function getCurrentUserData(): array
{
$user = new User();
$userRepository = new UserRepository();
return [
$user->getName(),
$user->getLastName(),
$user->getEmail(),
$user->getMobileNumber(),
$user->getDateTime(),
] ;
}
Answer the question
In order to leave comments, you need to log in
Repositories must be obtained from EntityManager
, not created by ourselves.
To do this, you need to UserRepository
register the entity in the mapping
@ORM\Entity(repositoryClass="UserRepository")
More details in the documentation
https://www.doctrine-project.org/projects/doctrine...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question