|
12 | 12 | use OCP\AppFramework\Http\TemplateResponse; |
13 | 13 |
|
14 | 14 | /** |
15 | | - * Provides template lookup and convenience helpers for rendering pages. |
16 | | - * |
17 | | - * @warning Callers are expected to handle HTTP status selection. Only error |
18 | | - * related helpers manage status selection and execution termination. |
| 15 | + * Provides helpers for locating and rendering server-side templates. |
19 | 16 | * |
20 | 17 | * @since 32.0.0 |
21 | 18 | */ |
22 | 19 | interface ITemplateManager { |
23 | 20 | /** |
24 | | - * Create a template instance for the given app/template pair. |
25 | | - * |
26 | | - * The returned template uses the given rendering mode and will include a |
27 | | - * CSRF token when accessed by default. |
| 21 | + * Create a template for the given app and template name. |
28 | 22 | * |
29 | 23 | * @param string $app App identifier that owns the template |
30 | 24 | * @param string $name Template name without extension |
31 | | - * @param TemplateResponse::RENDER_AS_* $renderAs Template rendering mode |
32 | | - * @param bool $registerCall Whether a CSRF request token should be included |
33 | | - * |
| 25 | + * @param TemplateResponse::RENDER_AS_* $renderAs Rendering mode / layout wrapper |
| 26 | + * @param bool $registerCall Whether to register the request for CSRF token injection |
34 | 27 | * @throws TemplateNotFoundException if the template cannot be found |
35 | | - * |
36 | 28 | * @since 32.0.0 |
37 | 29 | */ |
38 | 30 | public function getTemplate(string $app, string $name, string $renderAs = TemplateResponse::RENDER_AS_BLANK, bool $registerCall = true): ITemplate; |
39 | 31 |
|
40 | 32 | /** |
41 | | - * Render and print a simple guest page. |
| 33 | + * Render and print a guest page. |
42 | 34 | * |
43 | | - * Assigns the provided parameters to the template before rendering. |
| 35 | + * Assigns the provided parameters to the template before printing it. |
| 36 | + * This helper does not set an HTTP status code or terminate execution. |
44 | 37 | * |
45 | 38 | * @param string $application App identifier that owns the template |
46 | 39 | * @param string $name Template name without extension |
47 | | - * @param array $parameters Variables assigned to the template |
48 | | - * |
| 40 | + * @param array $parameters Template variables to assign |
49 | 41 | * @since 32.0.0 |
50 | 42 | */ |
51 | 43 | public function printGuestPage(string $application, string $name, array $parameters = []): void; |
52 | 44 |
|
53 | 45 | /** |
54 | | - * Render and print a fatal error page, then terminate execution. |
| 46 | + * Render and print an error page, then terminate execution. |
55 | 47 | * |
56 | | - * The implementation first tries a themed HTML response, then falls back to |
57 | | - * an unthemed HTML template, and finally to a plain-text error response. |
| 48 | + * Sets the HTTP status code before rendering. Falls back from the themed |
| 49 | + * error page to an unthemed template and finally to plain-text output if |
| 50 | + * rendering fails. |
58 | 51 | * |
59 | 52 | * @param string $error_msg Error message to show |
60 | | - * @param string $hint Optional hint shown below the message (needs to be escaped) |
| 53 | + * @param string $hint Optional hint shown with the error |
61 | 54 | * @param int $statusCode HTTP status code to send |
62 | | - * |
63 | 55 | * @since 32.0.0 |
64 | 56 | */ |
65 | 57 | public function printErrorPage(string $error_msg, string $hint = '', int $statusCode = 500): never; |
66 | 58 |
|
67 | 59 | /** |
68 | 60 | * Render and print an exception error page, then terminate execution. |
69 | 61 | * |
70 | | - * The exception details are shown in the HTML template, with additional debug |
71 | | - * information when debug mode is enabled. Falls back to a plain-text error |
72 | | - * page if rendering fails. |
| 62 | + * Sets the HTTP status code before rendering. Uses the exception to populate |
| 63 | + * the error view and falls back to plain-text output if rendering fails. |
73 | 64 | * |
74 | | - * @param \Throwable $exception The exception to render |
| 65 | + * @param \Throwable $exception Exception to render |
75 | 66 | * @param int $statusCode HTTP status code to send |
76 | | - * |
77 | 67 | * @since 32.0.0 |
78 | 68 | */ |
79 | 69 | public function printExceptionErrorPage(\Throwable $exception, int $statusCode = 503): never; |
|
0 commit comments