public function getEntityProxy($entity, BusinessEntity $businessEntity, EntityManager $em) { $entityProxy = $em->getRepository('Victoire\\Bundle\\CoreBundle\\Entity\\EntityProxy')->findOneBy([$businessEntity->getId() => $entity]); if (!$entityProxy) { $entityProxy = new EntityProxy(); $entityProxy->setEntity($entity, $businessEntity->getName()); } return $entityProxy; }
/** * Find the pagePatterns of the business entity * @param BusinessEntity $businessEntity * * @return array The list of pagePatterns */ public function findPageByBusinessEntityAndPattern(BusinessEntityPagePattern $pattern, $entity, BusinessEntity $businessEntity) { $qb = $this->createQueryBuilder('businessEntityPage'); $qb->join('businessEntityPage.entityProxy', 'proxy'); $qb->join('businessEntityPage.template', 'template'); $qb->join('proxy.' . $businessEntity->getId(), 'entity'); $qb->where('template.id = :patternId'); $qb->andWhere('entity.id = :entityId'); $qb->setParameter(':patternId', $pattern); $qb->setParameter(':entityId', $entity->getId()); $result = $qb->getQuery()->getOneOrNullResult(); return $result; }
/** * Find the pagePatterns for the business entity * @param BusinessEntity $businessEntity * * @return array The list of pagePatterns */ public function findPagePatternByBusinessEntity(BusinessEntity $businessEntity) { return $this->getPagePatternByBusinessEntity($businessEntity->getId())->getQuery()->getResult(); }