Rev 1265 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1265 | Rev 1405 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | For the plugin-to-plugin communication, the PHP interfaces offered by the plugin *MUST* |
21 | For the plugin-to-plugin communication, the PHP interfaces offered by the plugin *MUST* |
22 | have the prefix "INTF_OID_" followed by an OID (dots replaced by underscores), e.g. "INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1". |
22 | have the prefix "INTF_OID_" followed by an OID (dots replaced by underscores), e.g. "INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1". |
23 | The OIDplus autoloader will make sure that interfaces following this naming convention |
23 | The OIDplus autoloader will make sure that interfaces following this naming convention |
24 | are replaced with an empty "fake" interface if the plugin defining the interface is not installed. |
24 | are replaced with an empty "fake" interface if the plugin defining the interface is not installed. |
25 | Therefore, the interface is "optional" and there won't be a fatal error if a plugin implements (references) |
25 | Therefore, the interface is "optional" and there won't be a fatal error if a plugin implements (references) |
26 | a feature that is not known. |
26 | a feature that is unknown. |
27 | 27 | ||
28 | Previously, the plugin-to-plugin-communication used a function called implementsFeature(), which |
28 | Previously, the plugin-to-plugin-communication used a function called implementsFeature(), which |
29 | has been discontinued as of 26 March 2023, because types could not be easily checked. |
29 | has been discontinued as of 26 March 2023, because types could not be easily checked. |
30 | 30 | ||
31 | ### Usage example (new method): |
31 | ### Usage example (new method): |
32 | 32 | ||
33 | // Implement feature in a class: |
33 | Implement feature in a class: |
- | 34 | ||
34 | class OIDplusPageAdminNostalgia |
35 | class OIDplusPageAdminNostalgia |
35 | extends OIDplusPagePluginAdmin |
36 | extends OIDplusPagePluginAdmin |
36 | implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 /* getNotifications */ |
37 | implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 /* getNotifications */ |
37 | { |
38 | { |
38 | public function getNotifications(...) { |
39 | public function getNotifications(...) { |
39 | /* Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 */ |
40 | /* Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 */ |
40 | ... |
41 | ... |
41 | } |
42 | } |
42 | } |
43 | } |
43 | 44 | ||
44 | // Call all plugins supporting the feature: |
45 | Call all plugins supporting the feature: |
- | 46 | ||
45 | foreach (OIDplus::getAllPlugins() as $plugin) { |
47 | foreach (OIDplus::getAllPlugins() as $plugin) { |
46 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8) { |
48 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8) { |
47 | $plugin->getNotifications(...); |
49 | $plugin->getNotifications(...); |
48 | } |
50 | } |
49 | } |
51 | } |
50 | 52 | ||
51 | ### Old method (deprecated as of 26 March 2023): |
53 | ### Old method (deprecated as of 26 March 2023): |
52 | 54 | ||
53 | // Implement feature in a class: |
55 | Implement feature in a class: |
- | 56 | ||
54 | class OIDplusPageAdminNostalgia |
57 | class OIDplusPageAdminNostalgia |
55 | extends OIDplusPagePluginAdmin |
58 | extends OIDplusPagePluginAdmin |
56 | { |
59 | { |
57 | public function implementsFeature(string $oid): bool { |
60 | public function implementsFeature(string $oid): bool { |
58 | if ($oid == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; |
61 | if ($oid == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; /*getNotifications*/ |
59 | return false; |
62 | return false; |
60 | } |
63 | } |
61 | public function getNotifications(...) { |
64 | public function getNotifications(...) { |
62 | /* Implements feature 1.3.6.1.4.1.37476.2.5.2.3.8 */ |
65 | /* Implements feature 1.3.6.1.4.1.37476.2.5.2.3.8 */ |
63 | ... |
66 | ... |
64 | } |
67 | } |
65 | } |
68 | } |
66 | 69 | ||
67 | // Call all plugins supporting the feature: |
70 | Call all plugins supporting the feature: |
- | 71 | ||
68 | foreach (OIDplus::getAllPlugins() as $plugin) { |
72 | foreach (OIDplus::getAllPlugins() as $plugin) { |
69 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.8')) { |
73 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.8')) { |
70 | $plugin->getNotifications(...); |
74 | $plugin->getNotifications(...); |
71 | } |
75 | } |
72 | } |
76 | } |