'', 'content_type' => '', ); } return $adapter->format( $printer, $template ); } /** * Resolve the HTTP content type for a printer when no template is in hand. * * Two callers have a printer but no template to resolve against. The * diagnostic builder always does — its payload is hand-built, not rendered * from a template — and always gets the provider's declared type. The * reprint path reaches it only when the source job's template can no longer * be rendered on the printer, and even then only when the job carries no * `pn_kind`; a job that has one keeps its stored content type instead, so * the two halves cannot drift apart. * * PrintNode therefore reports its PDF default here even for a printer in raw * mode, unlike resolve(), which sees the engine and can honour * `printnode_format`. Neither caller can act on the difference: the * diagnostic builder throws for PrintNode before it gets here, and the * reprint path's `pn_kind` condition above keeps a raw job away from this * answer. Prefer resolve() wherever a template is in hand — it answers both * halves of the pairing at once. * * @param array $printer Printer configuration. * * @return string */ public function content_type_for_printer( array $printer ): string { $provider = Provider::normalize( \is_string( $printer['provider'] ?? null ) ? $printer['provider'] : null ); $adapter = Provider::adapter( $provider ); return null === $adapter ? 'application/octet-stream' : $adapter->content_type(); } }