Commit b5f025c2 authored by Fabien Potencier's avatar Fabien Potencier

merged branch stof/swift_autoload (PR #373)

Commits
-------

1c41a6be Removed the swiftmailer autoloading from the service provider

Discussion
----------

Removed the swiftmailer autoloading from the service provider

It is now handled by composer directly once swiftmailer/swiftmailer#212 is merged.
parents 4d106637 1c41a6be
...@@ -26,9 +26,6 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface ...@@ -26,9 +26,6 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
$app['swiftmailer.options'] = array(); $app['swiftmailer.options'] = array();
$app['mailer'] = $app->share(function () use ($app) { $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']); return new \Swift_Mailer($app['swiftmailer.spooltransport']);
}); });
...@@ -85,10 +82,9 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface ...@@ -85,10 +82,9 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface
public function boot(Application $app) public function boot(Application $app)
{ {
// BC: to be removed before 1.0
if (isset($app['swiftmailer.class_path'])) { if (isset($app['swiftmailer.class_path'])) {
require_once $app['swiftmailer.class_path'].'/Swift.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.');
\Swift::registerAutoload($app['swiftmailer.class_path'].'/../swift_init.php');
} }
$app->finish(function () use ($app) { $app->finish(function () use ($app) {
......
...@@ -22,28 +22,15 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -22,28 +22,15 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
if (!is_dir(__DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib')) { 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() public function testSwiftMailerServiceIsSwiftMailer()
{ {
$app = new Application(); $app = new Application();
$app->register(new SwiftmailerServiceProvider(), array( $app->register(new SwiftmailerServiceProvider());
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->boot(); $app->boot();
$this->assertInstanceOf('Swift_Mailer', $app['mailer']); $this->assertInstanceOf('Swift_Mailer', $app['mailer']);
...@@ -53,9 +40,7 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -53,9 +40,7 @@ class SwiftmailerServiceProviderTest extends \PHPUnit_Framework_TestCase
{ {
$app = new Application(); $app = new Application();
$app->register(new SwiftmailerServiceProvider(), array( $app->register(new SwiftmailerServiceProvider());
'swiftmailer.class_path' => __DIR__.'/../../../../vendor/swiftmailer/swiftmailer/lib/classes',
));
$app->boot(); $app->boot();
$app['swiftmailer.spool'] = $app->share(function () { $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