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

Add View::existsLayout and View::existsPartial #2427

Closed
aleemb opened this issue May 14, 2014 · 1 comment
Closed

Add View::existsLayout and View::existsPartial #2427

aleemb opened this issue May 14, 2014 · 1 comment

Comments

@aleemb
Copy link

aleemb commented May 14, 2014

Thanks for adding View::exists, it is really handy. However, when checking for existence of layouts and partials there are still a few issues.

$view = 'hello';
$this->exists("layouts/$view"); // returns true

The above is a naive approach. The more correct approach is:

$view = 'hello';
// workaround for getLayoutsDir returning empty string
$defaultLayoutsDir = 'layouts/';
$layoutsDir = $this->getLayoutsDir() ?: $defaultLayoutsDir;
$this->exists("{$layoutsDir}{$view}");

Problem: The $defaultLayoutsDir must be kept in sync with the framework which at present defines it as layouts/. Even though that value may not ever change, it is still something the user should not have to write as it is framework-specific behaviour.

Proposed Solution 1:
getLayoutsDir() should return layouts/. This would appear to be the correct behaviour since layouts/ is really the default directory. Currently getLayoutsDir() returns an empty string, which is technically a lie. Though I would prefer this, I understand that it can break backward compatibility for a lot of users.

Proposed Solution 2:
Add View::existsLayout and View::existsPartial.

As an aside, layouts/ is hard-coded in the view and these would be better off assigned to a variable so they can be re-used.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@sergeyklay
Copy link
Contributor

I'm closing this issue due to the lack of any reaction and I don't want a bunch of these lying around. I'd like to add support for anything/everything at some point, but keeping the issue open doesn't help that. If anyone wants to get started, I'd love that.

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

No branches or pull requests

2 participants