Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

New Template resolver just like PSR-4 autoloader #6437

Closed
ojhaujjwal opened this issue Jul 3, 2014 · 11 comments
Closed

New Template resolver just like PSR-4 autoloader #6437

ojhaujjwal opened this issue Jul 3, 2014 · 11 comments
Assignees
Milestone

Comments

@ojhaujjwal
Copy link
Contributor

I could not think of a better issue title.

Currently we should have "application" folder inside "view" folder of Application module. This is something like PSR-0 autoloader.

In a lot of cases, we only have one folder inside view folder of a module. So, I think there should be a new template resolver.

// in module/Album/config/module.config.php
return [
    'view_manager' => [
        'alias_template_path_stack' => [
            'album' => [__DIR__ . '/../view',]
        ]
    ]
];

If this is done, we should not create "album" folder inside "view" folder of Album module.

I hope it's clear.

@ojhaujjwal
Copy link
Contributor Author

If this is not clear, this issue states that we should have a new template path resolver just like AliasPathStackResolver of AssetManager

@Martin-P
Copy link
Contributor

Martin-P commented Jul 3, 2014

I think the same comment as in issue #6357 (comment) applies here?

@ojhaujjwal
Copy link
Contributor Author

@Martin-P No, I am talking about a template path resolver like PSR-4 autoloader.

@danizord
Copy link
Contributor

danizord commented Jul 3, 2014

👍

@Ocramius
Copy link
Member

Ocramius commented Jul 3, 2014

👍 as well. Do you think you're able to build it?

@Martin-P
Copy link
Contributor

Martin-P commented Jul 3, 2014

@Ocramius Just for my understanding: you want to remove aliases in the ServiceManager in issue #5500, but introduce them here? Where is the consistency in this?

@ojhaujjwal
Copy link
Contributor Author

@Ocramius Okay. I will build it.

@Ocramius
Copy link
Member

Ocramius commented Jul 3, 2014

@Martin-P it would be a different class here, not something set up by default. That's a decent segregation of concerns.

@adamlundrigan
Copy link
Contributor

So, just to be sure I'm getting it right, this new resolver works the same as ViewTemplatePathStack, except it doesn't include the first level of folder (one named like the module)?

Playing devil's advocate here...but is a separate resolver class necessary for this? Couldn't we add an option like enable_prefix to ViewTemplatePathStack to toggle the inclusion of the module-level folder? The developer-facing usage could still be the same, it would just eliminate the duplicated code between ViewTemplatePathStack and your new class, and your factory would create an instance of ViewTemplatePathStack with the flag turned off.

@weierophinney what's your take on this?

@ojhaujjwal
Copy link
Contributor Author

@adamlundrigan They are different. The ViewTemplatePathStack resolver looks for a template in the array of template paths. And, the new one PrefixPathStackResolver resolver, looks for prefix. Every prefix has its one array of template paths. So, the template with prefix like album/ will be only looked in its own array of template paths. To eliminate the duplicate code, I have made use of ViewTemplatePathStack in PrefixPathStackResolver. You can see #6441. Each prefix has it's own instance of ViewTemplatePathStack.

@Ocramius Ocramius added this to the 2.4.0 milestone Dec 5, 2014
@Ocramius Ocramius self-assigned this Dec 5, 2014
@Ocramius
Copy link
Member

Feature will be provided by #6963

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants