| 1 |
<?php |
| 2 |
/** |
| 3 |
* Loads an nginx.conf that bypasses caching. |
| 4 |
* |
| 5 |
* @package SolidWP\Performance |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Cache_Delivery\Nginx; |
| 11 |
|
| 12 |
use SolidWP\Performance\View\Contracts\View; |
| 13 |
use SolidWP\Performance\View\Exceptions\FileNotFoundException; |
| 14 |
|
| 15 |
/** |
| 16 |
* Loads an nginx.conf that bypasses caching. |
| 17 |
* |
| 18 |
* @package SolidWP\Performance |
| 19 |
*/ |
| 20 |
final class Bypass_Template_Loader { |
| 21 |
|
| 22 |
public const VIEW = 'cache/nginx-bypass'; |
| 23 |
|
| 24 |
/** |
| 25 |
* @var View |
| 26 |
*/ |
| 27 |
private View $view; |
| 28 |
|
| 29 |
/** |
| 30 |
* @param View $view The view renderer. |
| 31 |
*/ |
| 32 |
public function __construct( |
| 33 |
View $view |
| 34 |
) { |
| 35 |
$this->view = $view; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Get our nginx-bypass config template, with the dynamic values replaced. |
| 40 |
* |
| 41 |
* @throws FileNotFoundException If we can't find the view file. |
| 42 |
* |
| 43 |
* @return string |
| 44 |
*/ |
| 45 |
public function get(): string { |
| 46 |
return $this->view->render_to_string( self::VIEW ); |
| 47 |
} |
| 48 |
} |
| 49 |
|