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; }
public function getByBusinessEntityAndId(BusinessEntity $businessEntity, $id) { return $this->entityManager->getRepository($businessEntity->getClass())->findOneById($id); }
/** * Get the list of business properties usable for the url * * @param BusinessEntity $businessEntity * * @return array The list of business properties */ public function getBusinessProperties(BusinessEntity $businessEntity) { //the business properties usable in a url $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter'); //the business properties usable in a url $seoBusinessProps = $businessEntity->getBusinessPropertiesByType('seoable'); //the business properties are the identifier and the seoables properties $businessProperties = array_merge($businessProperties, $seoBusinessProps); return $businessProperties; }
/** * Must be called by the service victoire_core.helper.queriable_business_entity_helper. * * @param BusinessEntity $businessEntity * @param $id * * @throws \Exception * * @return mixed */ public function getByBusinessEntityAndId(BusinessEntity $businessEntity, $id) { if (!$this->entityManager) { throw new \Exception('EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service'); } return $this->entityManager->getRepository($businessEntity->getClass())->findOneById($id); }
/** * save BusinessEntity. */ public function saveBusinessEntity(BusinessEntity $businessEntity) { $businessEntities = $this->cache->get(BusinessEntity::CACHE_CLASSES); $businessEntities[$businessEntity->getClass()] = $businessEntity; $this->cache->save(BusinessEntity::CACHE_CLASSES, $businessEntities); }
/** * 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(); }