Skip to content

PluginBase

Viames Marino edited this page Feb 23, 2026 · 1 revision

Pair framework: PluginBase

Pair\Helpers\PluginBase is the abstract base for plugin-backed ActiveRecord models.

When to use

Use it when creating installable domain models that are tied to plugin manifests and version compatibility rules.

Main methods

  • isCompatibleWithApp(): bool
  • isCompatibleWithAppMajorVersion(): bool
  • Abstract contract:
  • getBaseFolder(): string
  • getPlugin(): Plugin
  • storeByPlugin(SimpleXMLElement $options): bool

Implementation examples

Minimal implementation

final class CustomModule extends \Pair\Helpers\PluginBase {

    public function getBaseFolder(): string
    {
        return APP_PATH . '/modules/custom';
    }

    public function getPlugin(): \Pair\Helpers\Plugin
    {
        return new \Pair\Helpers\Plugin();
    }

    public function storeByPlugin(\SimpleXMLElement $options): bool
    {
        return $this->store();
    }
}

Compatibility gate

$module = \Pair\Models\Module::find($id);

if ($module && !$module->isCompatibleWithApp()) {
    throw new RuntimeException('Plugin is not compatible with this app version');
}

Common pitfalls

  • Skipping compatibility checks before enabling a plugin.
  • Mixing plugin filesystem concerns with controller logic.

See also: Plugin, Module.

Clone this wiki locally