1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the pixelart Swiftmailer manipulator bundle. |
5
|
|
|
* |
6
|
|
|
* (c) pixelart GmbH |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Pixelart\Bundle\SwiftmailerManipulatorBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\DefinitionDecorator; |
17
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
18
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
19
|
|
|
|
20
|
|
|
class PixelartSwiftmailerManipulatorExtension extends Extension |
21
|
|
|
{ |
22
|
40 |
|
public function load(array $configs, ContainerBuilder $container) |
23
|
|
|
{ |
24
|
40 |
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
25
|
40 |
|
$loader->load('services.xml'); |
26
|
|
|
|
27
|
40 |
|
$configuration = $this->getConfiguration($configs, $container); |
28
|
40 |
|
$config = $this->processConfiguration($configuration, $configs); |
|
|
|
|
29
|
|
|
|
30
|
40 |
|
foreach ($config['mailers'] as $name => $mailer) { |
31
|
30 |
|
$this->configureMailer($name, $mailer, $container); |
32
|
24 |
|
} |
33
|
40 |
|
} |
34
|
|
|
|
35
|
30 |
|
private function configureMailer($name, array $mailer, ContainerBuilder $container) |
36
|
|
|
{ |
37
|
|
|
if ( |
38
|
30 |
|
(isset($mailer['prepend_subject']) && $mailer['prepend_subject']) |
39
|
12 |
|
|| (isset($mailer['prepend_body']) && $mailer['prepend_body']) |
40
|
18 |
|
) { |
41
|
30 |
|
$container->setParameter( |
42
|
30 |
|
sprintf('pixelart_swiftmailer_manipulator.mailer.%s.prepend_subject', $name), |
43
|
30 |
|
$mailer['prepend_subject'] |
44
|
18 |
|
); |
45
|
30 |
|
$container->setParameter( |
46
|
30 |
|
sprintf('pixelart_swiftmailer_manipulator.mailer.%s.prepend_body', $name), |
47
|
30 |
|
$mailer['prepend_body'] |
48
|
18 |
|
); |
49
|
|
|
|
50
|
30 |
|
$definitionDecorator = new DefinitionDecorator('pixelart_swiftmailer_manipulator.plugin.abstract'); |
51
|
|
|
$container |
52
|
30 |
|
->setDefinition( |
53
|
30 |
|
sprintf('pixelart_swiftmailer_manipulator.mailer.%s.plugin', $name), |
54
|
|
|
$definitionDecorator |
55
|
18 |
|
) |
56
|
30 |
|
->addArgument(sprintf('%%pixelart_swiftmailer_manipulator.mailer.%s.prepend_subject%%', $name)) |
57
|
30 |
|
->addArgument(sprintf('%%pixelart_swiftmailer_manipulator.mailer.%s.prepend_body%%', $name)) |
58
|
|
|
; |
59
|
|
|
|
60
|
|
|
$container |
61
|
30 |
|
->getDefinition(sprintf('pixelart_swiftmailer_manipulator.mailer.%s.plugin', $name)) |
62
|
30 |
|
->addTag(sprintf('swiftmailer.%s.plugin', $name)) |
63
|
|
|
; |
64
|
18 |
|
} |
65
|
30 |
|
} |
66
|
|
|
} |
67
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: