An open API service indexing awesome lists of open source software.

https://github.com/yohn/plugable


https://github.com/yohn/plugable

Last synced: 4 months ago
JSON representation

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'];
}
}
```