handlers[] = $handler; } /** * Finds the first registered handler that supports the given key and entity type. * * @param string $key The filter or orderby key from the REST request. * @param string $entity_type The entity type being queried. * * @return QueryHandlerInterface|null The matching handler, or null if none is found. */ public function find( string $key, string $entity_type ): ?QueryHandlerInterface { foreach ( $this->handlers as $handler ) { if ( $handler->supports( $key, $entity_type ) ) { return $handler; } } return null; } }