
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 0.72 KB | hits: 12 | expires: Never
How can i access repository functions in twig template in symfony2
{% for category in categories %}
--{{ category.name }}--
{% for product in getProducts(category.id,location) %}
--{{ product.name }}--
{% endfor %}
{% endfor %}
{% render '@MyBundle:Product:list' with {category: category.id} %}
class CategoryManager
{
public function loadCategoriesProductsForLocation($location)
{
$qb = $this->em->->createQueryBuilder();
$qb->addSelect('category');
$qb->addSelect('product');
$qb->from('MyBundleBundle:Category','category');
$qb->leftJoin('category.products','product',
ExprJoin::WITH, $qb->expr()->eq('product.location', $location));