registry = $registry; } /** * Resolve the supplied provider key to its item-lookup-capable * provider implementation. * * Lookup order: * * 1. If the registry has no entry for `$providerKey`, raise * {@see UnknownProviderException} per the resolver * contract. * * 2. If the registry entry exists but does not implement * {@see ItemLookupProviderInterface}, raise * {@see UnknownProviderException} for the same reason — * from the resolver-port perspective the key has no * item-lookup provider attached to it. * * 3. Otherwise return the matched provider. * * @param string $providerKey §4 stable provider key. * * @throws UnknownProviderException When no registered provider * matches the key, or when the * matched provider does not * implement * {@see ItemLookupProviderInterface}. */ public function resolveItemLookup( string $providerKey ): ItemLookupProviderInterface { if ( ! $this->registry->has( $providerKey ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Developer-facing message, never rendered to HTML. throw UnknownProviderException::forKey( $providerKey ); } $provider = $this->registry->get( $providerKey ); if ( ! $provider instanceof ItemLookupProviderInterface ) { // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Developer-facing message, never rendered to HTML. throw UnknownProviderException::forKey( $providerKey ); } return $provider; } /** * Underlying registry the adapter resolves against. * * Exposed so tests and diagnostics can probe the canonical * registry without re-resolving the binding from the service * container. */ public function registry(): ProviderRegistry { return $this->registry; } }