Vendor
Reference for the Vendor module: an in-memory registry of third-party vendors such as Stripe, Twilio and AWS. A capability module declares a vendor type and the interface shape its vendors must fill; each vendor sub-module registers itself as that type with a name, its config keys and its function implementations; the owning module resolves a vendor by name and pulls out its functions and config. It holds descriptors only, never the vendor's own code, and never decides which vendor is active.
This page is a pure reference. For how the framework fits together, see the Guide.
VendorConfig- the registry: declare vendor types, register vendors, and resolve them by name.VendorRegisterConfig- the collector used inside theVendorConfig::Registerclosure to describe a vendor.VendorTypeConfig- the collector used inside theVendorConfig::Typeclosure to declare a vendor type's shape.
VendorConfig
The registry, in two levels. Level one: a capability module declares a vendor type and
its shape with Type. Level two: a vendor sub-module registers itself as an
implementation of a type with Register. The owning module then resolves a
vendor by name with GetFunction and GetConfig. It is
deliberately ignorant of selection and of what the functions do, holding only names,
config-key names and callable references.
AllTypes
VendorConfig::AllTypes(): array
All declared vendor types.
Returns array The type definitions.
AllVendors
VendorConfig::AllVendors(): array
All registered vendors as a flat list, for the vendor directory.
Returns array The vendor definitions.
GetConfig
VendorConfig::GetConfig(string $type, string $name, string $key): mixed
A config value for the named vendor, read from the Config module under the vendor's module.
| Name | Type | Description |
|---|---|---|
$type | string | The vendor type. |
$name | string | The vendor id. |
$key | string | The config key to read. |
Returns mixed The configuration value.
GetFunction
VendorConfig::GetFunction(string $type, string $name, string $function): callable
The callable implementing the given function for the named vendor of the type.
| Name | Type | Description |
|---|---|---|
$type | string | The vendor type. |
$name | string | The vendor id. |
$function | string | The function name the vendor provides. |
Returns callable The vendor's implementation.
Has
VendorConfig::Has(string $type, string $name): bool
Whether a vendor of the given type and name is registered.
| Name | Type | Description |
|---|---|---|
$type | string | The vendor type. |
$name | string | The vendor id. |
Returns bool True when the vendor is registered.
Register
VendorConfig::Register(string $module, string $type, string $name, callable $details): void
Register a vendor as an implementation of a declared type. The details closure fills in the vendor's display name, config keys and function implementations, which are then validated against the type.
| Name | Type | Description |
|---|---|---|
$module | string | The registering vendor sub-module; namespaces its config. |
$type | string | The type it fulfils; must be declared first. |
$name | string | The vendor id, for example stripe or twilio. |
$details | callable | Closure using VendorRegisterConfig::Name, ConfigKey and Implement. |
Returns void
Type
VendorConfig::Type(string $module, string $type, callable $shape): void
Declare a vendor type and its shape: the interface functions a vendor must implement and any config common to the type.
| Name | Type | Description |
|---|---|---|
$module | string | The declaring module, for attribution. |
$type | string | The globally-unique type key vendors target. |
$shape | callable | Closure using VendorTypeConfig::RequireFunction and RequireConfig. |
Returns void
VendorNames
VendorConfig::VendorNames(string $type): array
The names of the vendors registered for a type. The owning module picks one, from its own config value or logic, then acts on it with GetFunction and GetConfig.
| Name | Type | Description |
|---|---|---|
$type | string | The vendor type. |
Returns array A list of vendor names.
VendorRegisterConfig
The collector used inside the closure passed to VendorConfig::Register. An
individual vendor fills in the shape its type declared: a display name, the config keys
it needs, and the implementations of the type's required functions. The implementations
are callable references, so the registry stays a thin set of descriptors.
ConfigKey
VendorRegisterConfig::ConfigKey(string $key, mixed $configType): void
Declare a config key this vendor needs. It is registered with the Config module under the registering module's namespace, so it is fully qualified even when another vendor uses the same key name.
| Name | Type | Description |
|---|---|---|
$key | string | The config key name. |
$configType | mixed | The Config type for the value. |
Returns void
Implement
VendorRegisterConfig::Implement(string $function, callable $callable): void
Provide the implementation of one of the type's required functions.
| Name | Type | Description |
|---|---|---|
$function | string | The required function name being implemented. |
$callable | callable | The implementation, usually a Class::Method reference. |
Returns void
Name
VendorRegisterConfig::Name(string $displayName): void
Set the human-readable name shown in the admin. Defaults to the vendor id.
| Name | Type | Description |
|---|---|---|
$displayName | string | The display name. |
Returns void
VendorTypeConfig
The collector used inside the closure passed to VendorConfig::Type. A
module declares the shape of its vendors here: the interface functions every vendor of
the type must implement, and any config keys common to all vendors of the type (usually
none, since config is per-vendor).
RequireConfig
VendorTypeConfig::RequireConfig(string $key, mixed $configType): void
Declare a config key that every vendor of this type needs. Rare, since config is usually per-vendor.
| Name | Type | Description |
|---|---|---|
$key | string | The config key name. |
$configType | mixed | The Config type for the value. |
Returns void
RequireFunction
VendorTypeConfig::RequireFunction(string $name): void
Declare a function the owning module will call on any vendor of this type.
| Name | Type | Description |
|---|---|---|
$name | string | The required function name. |
Returns void