Commit 1c41a6be authored by Christophe Coevoet's avatar Christophe Coevoet

Removed the swiftmailer autoloading from the service provider

It is now handled by composer directly.
parent 4d106637
......@@ -26,9 +26,6 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
$app['swiftmailer.options'] = array();
$app['mailer'] = $app->share(function () use ($app) {
$r = new \ReflectionClass('Swift_Mailer');
require_once dirname($r->getFilename()).'/../../swift_init.php';
return new \Swift_Mailer($app['swiftmailer.spooltransport']);
});
......@@ -85,10 +82,9 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
public function boot(Application $app)
{
// BC: to be removed before 1.0
if (isset($app['swiftmailer.class_path'])) {
require_once $app['swiftmailer.class_path'].'/Swift.php';
\Swift::registerAutoload($app['swiftmailer.class_path'].'/../swift_init.php');
throw new \RuntimeException('You have provided the swiftmailer.class_path parameter. The autoloader has been removed from Silex. It is recommended that you use Composer to manage your dependencies and handle your autoloading. If you are already using Composer, you can remove the parameter. See http://getcomposer.org for more information.');
}
$app->finish(function () use ($app) {
......
......@@ -22,28 +22,15 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
if (!is_dir(__DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib')) {
$this->markTestSkipped('Swiftmailer submodule was not installed.');
$this->markTestSkipped('Swiftmailer dependency was not installed.');
}
}
public function testSwiftMailerServiceWhenClassPathIsDefinedLate()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider());
$app['swiftmailer.class_path'] = __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes';
$app->boot();
$this->assertInstanceOf('Swift_Mailer', $app['mailer']);
}
public function testSwiftMailerServiceIsSwiftMailer()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider(), array(
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->register(new SwiftmailerServiceProvider());
$app->boot();
$this->assertInstanceOf('Swift_Mailer', $app['mailer']);
......@@ -53,9 +40,7 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider(), array(
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->register(new SwiftmailerServiceProvider());
$app->boot();
$app['swiftmailer.spool'] = $app->share(function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment