[HttpFoundation] added an exception to MimeTypeGuesser::guess() when no guesser are available (closes #2636)

This commit is contained in:
Fabien Potencier 2011-11-14 13:21:49 +01:00
parent 0462a89562
commit d67fbe9e48

View File

@ -110,16 +110,14 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
throw new AccessDeniedException($path); throw new AccessDeniedException($path);
} }
$mimeType = null; if (!$this->guessers) {
throw new \LogicException('Unable to guess the mime type as no guesser are available.');
foreach ($this->guessers as $guesser) {
$mimeType = $guesser->guess($path);
if (null !== $mimeType) {
break;
}
} }
return $mimeType; foreach ($this->guessers as $guesser) {
if (null !== $mimeType = $guesser->guess($path)) {
return $mimeType;
}
}
} }
} }