-
Notifications
You must be signed in to change notification settings - Fork 2
AdapterRegistry
Pair\Core\AdapterRegistry is the process-local registry used by Pair v4 to hold explicitly configured adapters.
It is intentionally small. It is not a dependency injection container and it does not discover services automatically.
It is the adapter store commonly used by Runtime Extensions. Runtime Extensions are explicit bootstrap registrations through RuntimeExtensionInterface, while Installable Packages are ZIP/manifest packages handled by InstallablePackage and InstallablePackageRecord.
use Pair\Core\AdapterKeys;
use Pair\Core\Application;
$app = Application::getInstance();
$app->setAdapter(AdapterKeys::PAYMENTS, $stripeGateway);
$payments = $app->adapter(AdapterKeys::PAYMENTS, StripeGateway::class);Use require(...) when the application cannot continue without that adapter:
$payments = $app->adapters()->require(AdapterKeys::PAYMENTS, StripeGateway::class);Registers or replaces one adapter under a normalized capability name.
Names must be explicit stable keys such as:
cachemailerobservabilitypaymentsnotificationsaiui
The conventional names are available through Pair\Core\AdapterKeys.
Returns the adapter or null.
When $expectedType is provided, the adapter must implement or extend that class/interface.
Returns the adapter or throws a RuntimeException when it has not been registered.
Returns whether a capability has a registered adapter.
Removes one adapter.
Removes every registered adapter.
- Adapters are registered manually from application bootstrap or a Runtime Extension implementing
RuntimeExtensionInterface. - There is no automatic package discovery.
- Provider SDKs remain optional and should live in extension packages.
- Type checks are explicit through the optional
$expectedTypeargument.
See also: Application, RuntimeExtensionInterface, UiRenderer, Observability, Cache.