In controller
return $this->render(
'FrontBundle:Default:search.html.twig',
array(
'edition' => $edition, THIS ONE
'paginator' => $pagination,
'array_ed_id' => $editions_search,
'array_he_id' => $heading_search,
'text' => $text,
'seo' => $seo,
'result' => $result,
'testix' => 10
)
);
in Twig i need custom query value.getCount to count rows
{% for value in edition %}
<label><label class="" for="front_form_edition_s_{{ value.getId }}">
{{ value.getName }}</label>{{value.getCount}}</label>
in Edition entity i add custom function:
use Doctrine\ORM\Query\ResultSetMapping;
..........................
class Edition {
..........................
public function getCount()
{
$rsm = new ResultSetMapping();
$query = $entityManager->createNativeQuery('select count(*) from advert_edition where edition_id= ?', $rsm);
$query->setParameter(1, '16');
$users = $query->getResult();
return 10;
}
}
But this doesn't work! :( Please tell me how i can do that.
{{value.advertEdition|length}}or create a custom method inside your entityRepository.