Installing swiftmailer or other php components in Ariadne

9 views
Skip to first unread message

kevin uittenbosch

unread,
Jul 6, 2015, 5:24:26 AM7/6/15
to ariad...@googlegroups.com
Hi muze, 

Is it possible to install swiftmailer in ariadne? I can't find any documentation on the website about this :(

Regards,
Kevin

Auke van Slooten

unread,
Jul 6, 2015, 6:41:35 AM7/6/15
to ariad...@googlegroups.com
On 6-7-2015 11:24, kevin uittenbosch wrote:
Hi muze, 

Is it possible to install swiftmailer in ariadne? I can't find any documentation on the website about this :(

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

muze
Hoedemakerplein 2
7511 JP ENSCHEDE
T. 053 - 4308177
I. www.muze.nl
Reply all
Reply to author
Forward
0 new messages