| 1 |
<?php |
| 2 |
/** |
| 3 |
* The view contract. |
| 4 |
* |
| 5 |
* @package SolidWP\Performance |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace SolidWP\Performance\View\Contracts; |
| 11 |
|
| 12 |
use SolidWP\Performance\View\Exceptions\FileNotFoundException; |
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* The view contract. |
| 20 |
* |
| 21 |
* @internal |
| 22 |
* |
| 23 |
* @package SolidWP\Performance |
| 24 |
*/ |
| 25 |
interface View { |
| 26 |
|
| 27 |
/** |
| 28 |
* Renders a view. |
| 29 |
* |
| 30 |
* @example If the server path is /app/views, and you wish to load /app/views/admin/notice.php, |
| 31 |
* pass `admin/notice` as the view name. |
| 32 |
* |
| 33 |
* @param string $name The relative path/name of the view file without extension. |
| 34 |
* |
| 35 |
* @param mixed[] $args Arguments to be extracted and passed to the view. |
| 36 |
* |
| 37 |
* @throws FileNotFoundException If the view file cannot be found. |
| 38 |
* |
| 39 |
* @return void |
| 40 |
*/ |
| 41 |
public function render( string $name, array $args = [] ): void; |
| 42 |
|
| 43 |
/** |
| 44 |
* Renders a view and returns it as a string to be echoed. |
| 45 |
* |
| 46 |
* @example If the server path is /app/views, and you wish to load /app/views/admin/notice.php, |
| 47 |
* pass `admin/notice` as the view name. |
| 48 |
* |
| 49 |
* @param string $name The relative path/name of the view file without extension. |
| 50 |
* |
| 51 |
* @param mixed[] $args Arguments to be extracted and passed to the view. |
| 52 |
* |
| 53 |
* @throws FileNotFoundException If the view file cannot be found. |
| 54 |
* |
| 55 |
* @return string |
| 56 |
*/ |
| 57 |
public function render_to_string( string $name, array $args = [] ): string; |
| 58 |
} |
| 59 |
|