public function findByTemplate(Template $template) { $qb = $this->initialize(); $qb->where($qb->expr()->eq("Template.id", ":template_id"))->setParameter("template_id", $template->getId()); $result = $qb->getQuery()->getResult(); return $result; }
public function findByTemplate(Template $template, Resource $parent = null) { $culture = $this->getLanguageManager()->getCulture(); $context = $this->getContextManager()->getContext(); $module = $template->getModule(); $qb = $this->initialize(); $qb->addSelect("*"); $qb->from($this->buildEavQuery($module), EavTables::CONTAINER_PREFIX); // $qb = $this->createQueryBuilder(); // $qb->addSelect("*") $qb->where($qb->expr()->isNull(EavTables::CONTAINER_PREFIX . ".deleted"))->andWhere($qb->expr()->eq(EavTables::CONTAINER_PREFIX . ".context_id", ":context_id"))->setParameter("context_id", $context->getId())->andWhere($qb->expr()->eq(EavTables::CONTAINER_PREFIX . ".culture", ":culture"))->setParameter("culture", $culture); if ($parent) { $qb->andWhere($qb->expr()->eq("Resource.parent_id", ":parent_id"))->setParameter("parent_id", $parent->getId()); } else { $qb->andWhere($qb->expr()->isNull("Resource.parent_id", ":parent_id")); } $qb->andWhere($qb->expr()->eq("Template.template_id", ":template_id"))->setParameter("template_id", $template->getId())->orderBy(EavTables::CONTAINER_PREFIX . ".sequence", "ASC"); $result = $qb->getQuery()->getResult(); return $result; }