Skip to content

Commit b015037

Browse files
Merge pull request #157 from sumocoders/breadcrumb-dont-fail-on-not-found-entity
Don't fail on entities that are not found
2 parents 3fb76d5 + 5a97414 commit b015037

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/EventListener/BreadcrumbListener.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SumoCoders\FrameworkCoreBundle\EventListener;
44

55
use Doctrine\ORM\EntityManagerInterface;
6+
use SumoCoders\FrameworkCoreBundle\Exception\Breadcrumb\EntityNotFoundException;
67
use SumoCoders\FrameworkCoreBundle\ValueObject\Route;
78
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
89
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
@@ -95,12 +96,16 @@ private function processAttributeFromMethod(
9596
$this->addBreadcrumbsForParent($attributeInstance->getParent());
9697
}
9798

98-
$this->breadcrumbTrail->add(
99-
$this->generateBreadcrumb(
100-
$attributeInstance,
101-
$method
102-
)
103-
);
99+
try {
100+
$this->breadcrumbTrail->add(
101+
$this->generateBreadcrumb(
102+
$attributeInstance,
103+
$method
104+
)
105+
);
106+
} catch (EntityNotFoundException $e) {
107+
108+
}
104109
}
105110
}
106111

@@ -159,7 +164,7 @@ private function generateBreadcrumb(
159164
}
160165

161166
if (!is_object($attribute)) {
162-
throw new RuntimeException(
167+
throw new EntityNotFoundException(
163168
'Could not resolve entity ' . $name . ' with ID ' . $attributeId
164169
);
165170
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace SumoCoders\FrameworkCoreBundle\Exception\Breadcrumb;
4+
5+
final class EntityNotFoundException extends \RuntimeException
6+
{
7+
}

0 commit comments

Comments
 (0)