Skip to content

Commit decce7d

Browse files
author
Leny BERNARD
committed
Merge pull request #401 from Charlie-Lucas/feature/1.5-allow-to-use-directly-the-entity-id-to-find-a-business-page
allow to pass directly the entity id in find BP method in BusinessPag…
2 parents 5fcc974 + b70314d commit decce7d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Bundle/BusinessPageBundle/Repository/BusinessPageRepository.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
class BusinessPageRepository extends EntityRepository
1313
{
1414
/**
15-
* Find the pagePatterns of the business entity.
15+
* Find the pagePatterns of the business entity.
1616
*
17-
* @param BusinessEntity $businessEntity
17+
* @param BusinessTemplate $pattern
18+
* @param object $entity | int $entityId
19+
* @param BusinessEntity $businessEntity
1820
*
19-
* @return array The list of pagePatterns
21+
* @return mixed
2022
*/
2123
public function findPageByBusinessEntityAndPattern(BusinessTemplate $pattern, $entity, BusinessEntity $businessEntity)
2224
{
25+
if (is_object($entity)) {
26+
$entity = $entity->getId();
27+
}
2328
$qb = $this->createQueryBuilder('BusinessPage');
2429
$qb->join('BusinessPage.entityProxy', 'proxy');
2530
$qb->join('BusinessPage.template', 'template');
@@ -30,7 +35,7 @@ public function findPageByBusinessEntityAndPattern(BusinessTemplate $pattern, $e
3035
$qb->andWhere('entity.id = :entityId');
3136

3237
$qb->setParameter(':templateId', $pattern);
33-
$qb->setParameter(':entityId', $entity->getId());
38+
$qb->setParameter(':entityId', $entity);
3439
$result = $qb->getQuery()->getOneOrNullResult();
3540

3641
return $result;

0 commit comments

Comments
 (0)