From ff95e23859afbe592f6d8d52c909c883b025562a Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 13 Jan 2019 16:36:40 +0100 Subject: [PATCH] Optimized findOneByIdOrSlug function --- .../symfony/src/Repository/Source/SourceRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/symfony/src/Repository/Source/SourceRepository.php b/application/symfony/src/Repository/Source/SourceRepository.php index c6ae2a2..26e3f69 100644 --- a/application/symfony/src/Repository/Source/SourceRepository.php +++ b/application/symfony/src/Repository/Source/SourceRepository.php @@ -29,10 +29,10 @@ final class SourceRepository extends EntityRepository */ public function findOneByIdOrSlug(RequestedSourceInterface $requestedSource): ?SourceInterface { - try { + if ($requestedSource->hasId()) { return $this->find($requestedSource->getId()); - } catch (\Error $error) { - return $this->findOneBySlug($requestedSource->getSlug()); } + + return $this->findOneBySlug($requestedSource->getSlug()); } }