Hi,
yes, it is possible, but you may be better of writing a
(micro)service and connecting to that. If you create new low-level
components for Ariadne,
your code will only work with your own Ariadne installation that has
that component. On the other hand, we're working on a plugin system
for Ariadne
so perhaps this will be a nice test subject :)
Your options:
1) 'old school'. Create a mod_swiftmailer.php (or whatever you want
to call it) in ariadne/lib/modules/. This will be a facade or
adapter. You'll at least need a class pinp_swiftmailer. The prefix
'pinp_' is required. Any method in this class will be callable in
your pinp templates. It is up to you to make sure swiftmailer is
loaded (either using composer or by manually including the correct
files).
Usage:
<pinp>
load('mod_swiftmailer.php');
swiftmailer::doSomething();
an example can be found in lib/modules/mod_xmlrpc.php
2) AR (modern)
create a directory in ar with your vendor prefix, e.g. 'kevin' =>
ar/kevin/
create a file 'swiftmailer.php' with something like this:
<?php
ar_pinp::allow('ar_kevin_swiftmailer');
ar_pinp::allow('ar_kevin_swiftmailerClient', array(
'doSomething' ) );
class ar_kevin_swiftmailer extends arBase {
public static function client() {
return new ar_kevin_swiftmailerClient();
}
}
class ar_kevin_swiftmailerClient extends swiftmailer {
public function doSomething() {
...
}
}
The calls to ar_pinp tell Ariadne which methods pinp templates may
access. If you don't specify an array with methods, it will allow
all methods. The reason to create the ar_kevin_swiftmailerClient
class is to be able to change methods that require disk access to
something that uses file objects in ariadne instead, or other
changes that make it easier or more secure to work with in Ariadne.
Usage:
<?php
$mailClient = ar('kevin/swiftmailer')->client();
$mailClient->doSomething();
--
Auke van Slooten
Hoedemakerplein 2
7511 JP ENSCHEDE
T. 053 - 4308177
I. www.muze.nl