Hello, I'm new to PHP OO and Doctrine . I would like to return the value of a function inside another function. It's possible? Both are within the same class.
Function that will receive the result:
public function salvar(Request $request, EM $em)
{
$FinContaspagar = new FinContaspagar(
$_SESSION["grupo"],
$_SESSION["estabelecimento"],
$request->get('terceiro'),
/****************RESULTADO DA FUNÇÃO AQUI**********/,
$request->get('dtemissao'),
$request->get("dtvencimento")
);
$em->persist($FinContaspagar);
$em->flush();
return redirect('contas')->with('success_message', 'Cadastrado com sucesso');
}
Function that generates value:
public function insereCodigo(em $em){
$query = $em->createQuery('SELECT COALESCE(MAX(u.codigo+1),1) as Codigo
FROM ModuloFinanceiro\Entities\FinContaspagar u
WHERE u.grupo = :sessionGrupo
AND u.estabelecimento = :sessionEstabelecimento');
$query->setParameter('sessionGrupo',$_SESSION["grupo"])
->setParameter('sessionEstabelecimento',$_SESSION["estabelecimento"]);
$codigo = $query->getResult();
return $codigo[0]["Codigo"];
}
If it is not possible or not recommended to do this, how can I proceed?