forked from FriendsOfSymfony/FOSUserBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckForMailerPass.php
More file actions
52 lines (44 loc) · 1.54 KB
/
CheckForMailerPass.php
File metadata and controls
52 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* This file is part of the FOSUserBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\UserBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Flex\Recipe;
/**
* Checks to see if the mailer service exists.
*
* @author Ryan Weaver <ryan@knpuniversity.com>
*
* @deprecated since 2.1, "mailer" service should be optional
*/
class CheckForMailerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
// if the mailer isn't needed, then no error needed
if (!$container->has('fos_user.mailer')) {
return;
}
// the mailer exists, so all is good
if ($container->has('mailer')) {
return;
}
if ($container->findDefinition('fos_user.mailer')->hasTag('fos_user.requires_swift')) {
$message = 'A feature you activated in FOSUserBundle requires the "mailer" service to be available.';
if (class_exists(Recipe::class)) {
$message .= ' Run "composer require swiftmailer-bundle" to install SwiftMailer or configure a different mailer in "config/packages/fos_user.yaml".';
}
throw new \LogicException($message);
}
}
}