Files
opensourcepos/app/Helpers/plugin_helper.php
Ollama 66f7d70749 feat(plugins): add view hooks for injecting plugin content into core views
Add event-based view hook system allowing plugins to inject UI elements
into core views without modifying core files. Includes helper functions
and example CasposPlugin demonstrating the pattern.
2026-03-12 10:13:12 +00:00

27 lines
651 B
PHP

<?php
use CodeIgniter\Events\Events;
if (!function_exists('plugin_content'))
{
function plugin_content(string $section, array $data = []): string
{
$results = Events::trigger("view:{$section}", $data);
if (is_array($results))
{
return implode('', array_filter($results, fn($r) => is_string($r)));
}
return is_string($results) ? $results : '';
}
}
if (!function_exists('plugin_content_exists'))
{
function plugin_content_exists(string $section): bool
{
$observers = Events::listRegistered("view:{$section}");
return !empty($observers);
}
}