I have 2 apps: frontend, backend.
Front controllers are organized in such way:
/web/index.php <- frontend
/web/backend/index.php <- backend
The problem is in backend assets:
By default, symfony (AssetHelper?) computes assets path relative to application directory, for example, if I call $response->addJavascript('/sf/prototype/js/prototype/prototype.js'); in my backend app, the result will be:
<script type="text/javascript" src="/backend/sf/prototype/js/prototype.js"></script>
What's this? I wanted js from /web directory, not from /web/backend! I thought, "/" in the beginning of path means /web dir!
Looking into _compute_public_path i found, that $sf_relative_url_root is prepended to $source anyway.
/branches/1.0/lib/helper/AssetHelper.php
291 function _compute_public_path($source, $dir, $ext, $absolute = false)
292 {
...
297
298 $request = sfContext::getInstance()->getRequest();
299 $sf_relative_url_root = $request->getRelativeUrlRoot();
300 if (0 !== strpos($source, '/'))
301 {
302 $source = $sf_relative_url_root.'/'.$dir.'/'.$source;
303 }
304
...
316
317 if ($sf_relative_url_root && 0 !== strpos($source, $sf_relative_url_root))
318 {
319 $source = $sf_relative_url_root.$source;
320 }
...
I think, the second condition should be removed. So, after this:
Url begining from "/" will stay as is or else $sf_relative_url_root - will be added to $source.
This is mor natural behavior, because "/js" means - absolute path to /web/js directory and "js" means relative path to app specific js directory.
This issue could be marked as enhancement but I think it is bug.
That should be:
291 function _compute_public_path($source, $dir, $ext, $absolute = false)
292 {
...
297
298 $request = sfContext::getInstance()->getRequest();
299 $sf_relative_url_root = $request->getRelativeUrlRoot();
300 if (0 !== strpos($source, '/'))
301 {
302 $source = $sf_relative_url_root.'/'.$dir.'/'.$source;
303 }
304
...
316
>REMOVED<
...