*/ private array $providers = []; public function register(MaterialProviderInterface $provider, string $label, string $description = '', string $settingsUrl = '', string $id = ''): void { $key = sanitize_key($id ?: $provider->get_id()); $this->providers[$key] = [ 'provider' => $provider, 'label' => $label, 'description' => $description, 'settings_url' => $settingsUrl, ]; } public function active(): MaterialProviderInterface { $id = sanitize_key((string) Settings::get('material_source', '')); return $this->providers[$id]['provider'] ?? $this->providers['internal']['provider'] ?? new NullMaterialProvider(); } public function get(string $id): ?MaterialProviderInterface { return $this->providers[$id]['provider'] ?? null; } public function definitions(): array { return $this->providers; } public function ids(): array { return array_keys($this->providers); } }