From eb0363e9a2354457541965191d5791658d0802c0 Mon Sep 17 00:00:00 2001 From: TullariS Date: Tue, 28 Jan 2020 13:07:30 +0000 Subject: [PATCH] Support for BladeCompiler::if() Added if() method so it can be used directly from the Blade instance (just like directive(), etc) The Facade Application has to be set or you will get an `Uncaught RuntimeException: A facade root has not been set` error --- src/Blade.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Blade.php b/src/Blade.php index 6fb75f4..9cacf1f 100644 --- a/src/Blade.php +++ b/src/Blade.php @@ -8,6 +8,7 @@ use Illuminate\Contracts\View\View; use Illuminate\Events\Dispatcher; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Facades\Facade; use Illuminate\View\Compilers\BladeCompiler; use Illuminate\View\Factory; use Illuminate\View\ViewServiceProvider; @@ -59,6 +60,11 @@ public function directive(string $name, callable $handler) { $this->compiler->directive($name, $handler); } + + public function if($name, callable $callback) + { + $this->compiler->if($name, $callback); + } public function exists($view): bool { @@ -120,5 +126,7 @@ protected function setupContainer(array $viewPaths, string $cachePath) 'view.compiled' => $cachePath, ]; }, true); + + Facade::setFacadeApplication($this->container); } }