[TYPO3-dev] Autoloading fails for "contrib" class
Ludwig Rafelsberger
ludwig.rafelsberger at gmx.at
Wed Sep 3 15:21:54 CEST 2014
Hi Caspar, hi everybody,
very good catch - that did the trick!
> It sounds like the Swift autoloader is not registered.
>
> Within the class file of MailMessage, there is a require_once statement
> to register the Swift autoloader. If you create an instance of that class,
> the autoloader should be registered.
> <code>
> require_once PATH_typo3 . 'contrib/swiftmailer/swift_required.php';
> </code>
Bingo! Manually requiring the Swift autoloader did resolve the issue. With
the current git version of TYPO3 the path is slightly different though:
(contrib/swiftmailer/lib/swift_required.php) but nevertheless it works now…
And with that in mind, I spotted another resolution, avoiding the manual
call to require():
Make sure to *first* create a MailMessage object
(via ObjectManager->get('TYPO3\\CMS\\Core\Mail\\MailMessage') and *then*
create the attachment.
That way the Swift autoloader is already in place when accessing the
\Swift_Attachment::fromPath() method. In my code I did it the other way round,
first creating the attachment – which left me without the autoloader at that
stage.
A big THANK YOU for helping!
Ludwig
More information about the TYPO3-dev
mailing list