Optimized findOneByIdOrSlug function

This commit is contained in:
Kevin Frantz 2019-01-13 16:36:40 +01:00
parent bea27399b7
commit ff95e23859

View File

@ -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());
}
}