컨트롤러나뭇 가지에 전역 변수를 표시하는 방법은 무엇입니까?
$count_em = $this->getDoctrine()->getRepository('AppBundle:St_Jude_Email');
$count_dql = $count_em->createQueryBuilder('c')
->select('count(c.flag)')
->where('c.flag = 0');
$flag_count = $count_dql->getQuery();
$count = $flag_count->getSingleScalarResult();
return $count;
Config.yml는
Twig:
globals:
count: '@AppBundle\Controller\countMail'
어떻게 나뭇 가지에 전역 수를 표시 ?? 죄송합니다. 심포니를 처음 사용하고 나뭇 가지에 '개수'를 표시하는 방법을 모릅니다. 템플릿을 렌더링하는 동안 예외가 발생했습니다 ("AppBundle \ Controller \ countMail 클래스의 객체를 문자열로 변환 할 수 없습니다."). {{count}}을 (를) 시도했지만 오류가 발생했습니다.
같은 서비스를 사용할 수 있습니다 : 그 후 다음 작업을 수행 할 수 있습니다 –