0

使用 composer.phar 更新 symfony/swiftmailer-bundle 到 v2.2.5 后,我得到这样的错误:

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing symfony/swiftmailer-bundle (v2.2.4)
  - Installing symfony/swiftmailer-bundle (v2.2.5)
    Loading from cache

Writing lock file
Generating autoload files



  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]  
  The service definition "swiftmailer.mailer" does not exist.                 



Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception



  [RuntimeException]                                                         
  An error occurred when executing the "'cache:clear --no-warmup'" command. 

降级到 2.2.4 后问题已解决

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing symfony/swiftmailer-bundle (v2.2.5)
  - Installing symfony/swiftmailer-bundle (v2.2.4)
    Loading from cache

Writing lock file
Generating autoload files
Clearing the cache for the dev environment with debug true
Installing assets using the hard copy option
Installing assets (part of code removed)
4

2 回答 2

1

您绝对应该使用mailerservice,因为它是正确 swiftmailer 服务的别名,无论它如何命名。例如 im v2.3.3 它是swiftmailer.mailer.default

但是你必须使用

$container->findDefinition('mailer');

这不像getDefinition()也解析别名,因此如果$serviceId参数是别名,您将获得基础定义。

于 2013-08-12T12:07:51.883 回答
0

触发错误的行是:

$definition = $container->getDefinition('swiftmailer.mailer') ;

错误是由更改服务名称引起的。直到 2.2.4 这个名字是

swiftmailer.mailer

从 2.2.5 开始,它是:

swiftmailer.mailer.abstract

我将行更改为:

$definition = $container->hasDefinition('swiftmailer.mailer') ? $container->getDefinition('swiftmailer.mailer') : $container->getDefinition('swiftmailer.mailer.abstract');

这修复了错误。

于 2013-08-12T08:45:32.343 回答