Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.5] Check for vendor views for each paths given in config/view.php #21636

Merged
merged 2 commits into from
Oct 13, 2017
Merged

[5.5] Check for vendor views for each paths given in config/view.php #21636

merged 2 commits into from
Oct 13, 2017

Conversation

yoramdelangen
Copy link
Contributor

@yoramdelangen yoramdelangen commented Oct 12, 2017

Currently I'm working on a project that requires a theme style views environment. There are multiple themes developed by a third party that only has access to themes folder. It's known what packages are used and views are included(e.g. laracasts/flash, backpack etc.). Those views can be different/changed per theme. But not thats not possible in the current situation.

In the current version of Laravel only the local resources/view/vendor/ folder will be checked for "Package Views".

Problem

When having multiple view paths in config/view.php or different location of the view path the "Package views" extending will not work.

Example:

// config/view.php
'paths' => [
    resource_path('views'),
    storage_path('themes'),
],

Each time the loadViewsFrom method will be used it only checks in resources/views/vendor/$namespace and it is not loading from themes/vendor/$namespace.

Another example:

// config/view.php
'paths' => [
    storage_path('themes/theme1'),
],

Different location will not be checked for extensions storage/themes/theme1/vendor/$namespace.

Solution

The fix/solution is backwards compatible and can be pushed to earlier version of Laravel aswel.

Instead of only looking for $this->app->resourcePath().'/views/vendor/'.$namespace in the loadViewsFrom method, loop through all view paths and check if there is a vendor/$namespace within the directory.

foreach ($this->app->config['view']['paths'] as $viewPath) {
    if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
        $this->app['view']->addNamespace($namespace, $appPath);
    }
}

@tillkruss tillkruss changed the title Check for vendor views for each paths given in config/view.php [5.5] Check for vendor views for each paths given in config/view.php Oct 12, 2017
@taylorotwell taylorotwell merged commit 7f084cd into laravel:5.5 Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants