The simplest way to understand my point is to start by explaining the
target behavior.

As my reflexion started with templates in mind, let's take this as an
example:

Given a ChildBundle < ParentBundle, the template files would be:

- ChildBundle/Resources/views/tpl.html.twig (ChB)
- ParentBundle/Resources/views/tpl.html.twig (PaB)

In an ideal world [1]:

- locateResource('@Child/Resources/views/tpl.html.twig') should return
(ChB)
- locateResource('@Parent/Resources/views/tpl.html.twig') should
return (ChB)

Now let's override the template in the app Resources folder:

- <app>/Resources/Child/Resources/views/tpl.html.twig (ChR) [2]

The behavior I would like to achieve is that:

- locateResource('@Child/Resources/views/tpl.html.twig', '<app>/
Resources') should return (ChR)
- locateResource('@Parent/Resources/views/tpl.html.twig', '<app>/
Resources') should return (ChR)

Q1: Do you think this makes sense ? [3]

Let's assume it makes sense, then comes an other question:

If we override the template from the parent Bundle:

- <app>/Resources/Parent/Resources/views/tpl.html.twig (PaR)

What should be the result of locateResource('@Child/Resources/views/
tpl.html.twig', '<app>/Resources', false) ?
A. [ChR, PaR, ChB, PaB]
B. [ChR, ChB, PaR, PaB]

The question would make more sense if you don't have (ChR) then
locateResource(..., ..., true) would return:
A. (PaR)
B. (ChB)

Q2: What would be the best order for files returned by
locateResource() ?
A. Resources first, then Bundles,
B. Resources and Bundles interlaced

Before going further I would like to get you POV on Q1 and Q2.

Thanks,
Victor

[1]
"ideal world" because this is not the case today, by my fault I must
admit, see
https://github.com/symfony/symfony/commit/788f63d460bdb2260f008d86cc094841f2e70894
This is something that need to be fixed.

[2]
I have submitted a PR because I think ChildBundle would be more
appropriate than Child here, see:
https://github.com/symfony/symfony/pull/416

[3]
There is no way this can be achieved with the current code.
You would need to call:
locateResource('@Child/Resources/Resources/views/tpl.html.twig',
'<app>/Resources')
to get (ChR)
and locateResource('@Parent/Resources/Resources/views/tpl.html.twig',
'<app>/Resources')
would return an InvalidArgumentException 'Unable to find file".

Some more notes:
- To me, B makes more sense for Q2,
- I have a proto working which could be ready very soon if we choose
to go in this direction.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to