Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[AsseticBundle] added factory worker to fix paths when use_controller…
… is on
- Loading branch information
1 parent
570a100
commit 5a9a657
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/Symfony/Bundle/AsseticBundle/Factory/Worker/PrependControllerWorker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Symfony\Bundle\AsseticBundle\Factory\Worker; | ||
|
||
use Assetic\Asset\AssetInterface; | ||
use Assetic\Factory\Worker\WorkerInterface; | ||
|
||
/** | ||
* Prepends a fake front controller to every asset's target URL. | ||
* | ||
* This worker should only be added when the use_controller configuration | ||
* option is true. It changes the target URL to include the front controller. | ||
* | ||
* @author Kris Wallsmith <kris@symfony.com> | ||
*/ | ||
class PrependControllerWorker implements WorkerInterface | ||
{ | ||
const CONTROLLER = 'front_controller/'; | ||
|
||
public function process(AssetInterface $asset) | ||
{ | ||
$targetUrl = $asset->getTargetUrl(); | ||
|
||
if ($targetUrl && '/' != $targetUrl[0] && 0 !== strpos($targetUrl, self::CONTROLLER)) { | ||
$asset->setTargetUrl(self::CONTROLLER.$targetUrl); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters