1
私はリポジトリメソッドを呼び出し、その中に配列のパラメータを渡します。しかし、配列は最初のパラメータの名前にちなんで命名されており、私はその理由を理解していません。名前が付けられていない配列
/**
* @param $month
* @param $year
* @return Conges[]
*/
public function getAllCongesPayes($year, $month)
{
return $this->congesRepository->getNbCongesByMonth(array('year' => $year, 'month' => $month, 'cngPaye' => true));
}
をし、エラーで、私はそれを見ることができます:
はここでコールだ
array('year' => array('year' => '2016', 'month' => '05', 'cngPaye' => true)))
そして、もちろん、それは唯一の配列がそれであるため、「引数2がありません」と言っています。これはそれは素晴らしいだろうなぜ起こるか、誰かが説明できる場合
$this->congesService = $this->get("intranet.conges_service");
$nbCongesPayes = $this->congesService->getAllCongesPayes('2016', '05');
:
public function getNbCongesByMonth($year, $month, $conge){
$qb = $this->createQueryBuilder('e');
$listOfEntities = $qb
->select('count(e) as nb')
// ->leftjoin('e.cngUsrLogin', 'u')
->where(
$qb->expr()->like('e.cngDateDebut',
$qb->expr()->literal($year.'-'.$month.'-%')
)
)
->andWhere('e.congesPayes = :conge')
// ->andWhere('u.usrGestionCra = 1')
// ->groupBy('e')
->setParameter('conge', $conge)
->getQuery()
->getResult();
return $listOfEntities;
}
とコントローラでのコール:ここ
は、リポジトリ方式です。
ありがとうございます。
私はこれを見てすぐ前に答えていました。実際には、getNbCongesByMonth($ year、$ month、$ conge)を 'getNbCongesByMonth($ array)'に変更するのではなく、 'return $ this-> congesRepository-> getNbCongesByMonth(array( ' $ this-> congesRepository-> getNbCongesByMonth($ year、$ month、true); 'を返します。これは、配列のパラメータをよりよく公開します。 – Terenoth
ああええ、素敵:)実際にそれは価値があった^ ^ありがとう! –