-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-test.php
More file actions
44 lines (35 loc) · 1.08 KB
/
plugin-test.php
File metadata and controls
44 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
error_reporting(0);
function __autoload($classname)
{
require_once $classname.".php";
}
// First, create an instance. We'll probably do this in our bootstrap.
$pluginMGR = new PluginManager();
// then create a plugin or two
$ship = new ShippingPlugin();
$pay = new PaymentPlugin();
// now stash it
$pluginMGR->offsetSet('shipping', $ship);
$pluginMGR->offsetSet('payment', $pay);
// optionally, stash it in your main app registry via the usual Zend_Registry class
// LATER ...
// in a page/route/controller thingee, we'd do something like this.
echo "exec all\n";
$pluginMGR->execPlugins('all');
// or this
echo "exec some\n";
$pluginMGR->execPlugins(array('payment', 'shipping'));
// or just one
echo "exec just one\n";
$pluginMGR->execPluginByName('shipping');
// now make it go away
echo "unregister the plugin\n";
$pluginMGR->unregisterPlugin('shipping');
// we now cannot use the shipping plugin any more in the context of this script
echo "try to re-exec\n";
try {
$pluginMGR->execPluginByName('shipping');
} catch (Exception $e) {
echo "Problem: ",$e->getMessage(),"\n";
}