Я думаю, вам просто нужно изменить тип возврата
public function findOneByAccountCode(string $accountCode): ?Bank
{
try {
return $this->createQueryBuilder('a')
->innerJoin('a.bank', 'b')
->where('a.code = :code')
->setParameter('code', $accountCode)
->getQuery()
->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
return null;
}
}
с
: ?Bank
на
: ?Account
public function findOneByAccountCode(string $accountCode): ?Account
{
try {
return $this->createQueryBuilder('a')
->innerJoin('a.bank', 'b')
->where('a.code = :code')
->setParameter('code', $accountCode)
->getQuery()
->getOneOrNullResult();
} catch (NonUniqueResultException $e) {
return null;
}
}