https://github.com/yohn/plugable
https://github.com/yohn/plugable
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yohn/plugable
- Owner: Yohn
- License: mit
- Created: 2024-08-18T00:23:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-18T00:25:52.000Z (almost 2 years ago)
- Last Synced: 2025-06-24T20:11:30.652Z (12 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Yohns\Core\Plugable
```php
Loaded Plugins:\n";
print_r($loadedPlugins);
echo "";
// Add hooks
Plugable::addHook('startup', function() {
echo "Startup hook executed!
";
});
Plugable::addHook('shutdown', function() {
echo "Shutdown hook executed!
";
});
// Execute the 'startup' event hooks
Plugable::doHook('startup');
// Add a filter
Plugable::addFilter('content_filter', ['content' => 'Original content']);
// Execute the filter for 'content_filter'
$result = Plugable::doFilter('content_filter', function(array $data) {
// Modify the filtered data
$data[0]['content'] = 'Filtered content';
return $data;
});
echo "
Filtered Data:\n";
print_r($result);
echo "
";
// Execute the 'shutdown' event hooks
Plugable::doHook('shutdown');
```
```php
//-- loading plugins
foreach ($loadedPlugins as $k => $v) {
if ($v['IncludeFiles'] != '') {
if (is_array($v['IncludeFiles'])) {
foreach ($v['IncludeFiles'] as $fi) {
if (is_file($pluginDir . $k . '/' . $fi)) {
include ($pluginDir . $k . '/' . $fi);
} else {
die($pluginDir . $k . '/' . $fi . ' file was not found');
}
}
}
}
if ($v['Route'] != '') {
$Routes[] = $v['Route'];
}
}
```