This topic might be in the wrong board, but as this thread concerns installing a package I find it most fitting here.
I’m busy to update modSwiftMailer to the latest xPDO standards when it comes down to installing, updating and uninstalling. This is also meant as a small learning project and will later be applied to my huge (still) closed source components and others.
The fun bit is the setup, of course. I’ve sort of figured out with the help of Quip and Gallery how it all comes together, and by analysing the xPDOTransport and xPDOFileTransport-er. Currently I’ve got a working example to test all functionality.
<?php
ob_start();
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
echo 'Install';
break;
case xPDOTransport::ACTION_UPGRADE:
echo 'Upgrade';
break;
case xPDOTransport::ACTION_UNINSTALL:
echo 'Uninstall!';
break;
}
echo 'Variables: ';
print_r(array_keys(get_defined_vars()));
echo 'Objects: ';
$vars = get_defined_vars();
foreach($vars as $key => $var) {
if ($key == 'modx' || $key == 'package') {
continue;
}
echo $key.'::'.print_r($var);
}
$modx->log(1, xPDOTransport::PACKAGE_ACTION.' '.ob_get_contents());
return '<pre style="max-height: 300px; overflow: auto;">'.ob_get_contents().'<pre>';
First, I’m collecting all output with ob_start as I want it on-screen all at one. Next I print ALL keys that are available to me with the dollar sign ("$"). Amoung many it, of course, includes $modx. I don’t want the entire output of $modx and $package on-screen since that’ll flood the browser in most cases.
Now, I’ve got it working for the most part, but the uninstall action is never called. I get no output when installing which I’d expect to get. No logs or what ever. This would mean I can’t clean up after the component is installed, like deleting cache files, assets from the assets folder or even system settings (they might be linked to the namespace, not sure on that).
So the main question is, how to I implement UNINSTALL functionality AND does anybody have some kind of example for me to study and perhaps even use/improve.
Thanks in advance.