Skip to content

Commit 93f3b00

Browse files
committed
Fix DirectoryNotFoundException when running view:cache without published views
The service provider now guards the published vendor views path with is_dir() before registering it, mirroring the existing pattern used for translations. This prevents php artisan view:cache from failing when vendor views have not been published.
1 parent 246fe82 commit 93f3b00

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to `laravel-cookie-guard` will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## v4.1.13 - Fix `view:cache` failure when vendor views are not published
9+
10+
- Fixed a `DirectoryNotFoundException` thrown by `php artisan view:cache` when the package's vendor views had not been published. The service provider now only registers the published views path if it actually exists, falling back to the bundled package views otherwise.
11+
812
## v4.1.6 - Bug Fixes & Improvements
913

1014
- Fixed the issue with the undefined `$accordionHeader` in the cookie consent dialog.

src/LaravelCookiesConsentServiceProvider.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ public function boot(): void {
2323
$this->loadTranslationsFrom($packagePath, 'cookies_consent');
2424
}
2525

26-
$this->loadViewsFrom([
27-
resource_path('views/vendor/scify/laravel-cookie-guard'),
28-
__DIR__ . '/../resources/views',
29-
], 'cookies_consent');
26+
$viewPaths = [__DIR__ . '/../resources/views'];
27+
$publishedViewPath = resource_path('views/vendor/scify/laravel-cookie-guard');
28+
29+
if (is_dir($publishedViewPath)) {
30+
array_unshift($viewPaths, $publishedViewPath);
31+
}
32+
33+
$this->loadViewsFrom($viewPaths, 'cookies_consent');
3034

3135
$this->publishes([
3236
__DIR__ . '/../resources/views/components/' => resource_path('views/vendor/scify/laravel-cookie-guard/components'),

0 commit comments

Comments
 (0)