Skip to content

Commit

Permalink
Show both missing packages in the same error message
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Feb 1, 2020
1 parent 6f29d8d commit f462285
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Symfony/Bridge/Twig/Mime/NotificationEmail.php
Expand Up @@ -41,12 +41,17 @@ class NotificationEmail extends TemplatedEmail

public function __construct(Headers $headers = null, AbstractPart $body = null)
{
$missingPackages = [];
if (!class_exists(CssInlinerExtension::class)) {
throw new \LogicException(sprintf('You cannot use "%s" if the CSS Inliner Twig extension is not available; try running "composer require twig/cssinliner-extra".', static::class));
$missingPackages['twig/cssinliner-extra'] = ' CSS Inliner';
}

if (!class_exists(InkyExtension::class)) {
throw new \LogicException(sprintf('You cannot use "%s" if the Inky Twig extension is not available; try running "composer require twig/inky-extra".', static::class));
$missingPackages['twig/inky-extra'] = 'Inky';
}

if ([] !== $missingPackages) {
throw new \LogicException(sprintf('You cannot use "%s" if the %s Twig extension%s not available; try running "composer require %s".', static::class, implode(' and ', $missingPackages), \count($missingPackages) > 1 ? 's are' : ' is', implode(' ', array_keys($missingPackages))));
}

parent::__construct($headers, $body);
Expand Down

0 comments on commit f462285

Please sign in to comment.