Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Cache media files which are not stored in the application path
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilien Escalle committed Nov 7, 2013
1 parent d1b218c commit 1900bd9
Show file tree
Hide file tree
Showing 61 changed files with 592 additions and 521 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AssetsBundle, v3.1
AssetsBundle, v3.2
=======

[![Build Status](https://travis-ci.org/neilime/zf2-assets-bundle.png?branch=master)](https://travis-ci.org/neilime/zf2-assets-bundle)
Expand Down
2 changes: 1 addition & 1 deletion src/AssetsBundle/Controller/ToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function renderAssetsAction(){
$oAssetsBundleService->getOptions()->setRenderer(new \Zend\View\Renderer\PhpRenderer());

//Start process

$oConsole->writeLine('');
$oConsole->writeLine('======================================================================', \Zend\Console\ColorInterface::GRAY);
$oConsole->writeLine('Render all assets for '.($oAssetsBundleService->getOptions()->isProduction()?'production':'development'), \Zend\Console\ColorInterface::GREEN);
Expand Down Expand Up @@ -51,6 +50,7 @@ public function renderAssetsAction(){
->setModuleName($sModuleName)
->setControllerName(\AssetsBundle\Service\ServiceOptions::NO_CONTROLLER)
->setActionName(\AssetsBundle\Service\ServiceOptions::NO_ACTION);

$oAssetsBundleService->renderAssets();

foreach(array_diff_key($aConfiguration['assets'][$sModuleName], $aUnwantedKeys) as $sControllerName => $aConfig){
Expand Down
9 changes: 8 additions & 1 deletion src/AssetsBundle/Service/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,14 @@ private function cacheMedias(array $aMediasPath){
:$sMediaPath;

//If media is not in asset directory
if($sCacheMediaPath === $sMediaPath)$sCacheMediaPath = str_ireplace(getcwd(),$sCachePath,$sMediaPath);
if($sCacheMediaPath === $sMediaPath){

$sCacheMediaPath = str_ireplace(getcwd(),$sCachePath,$sMediaPath);

//If media is not in application directory
if($sCacheMediaPath === $sMediaPath)$sCacheMediaPath = $sCachePath.DIRECTORY_SEPARATOR.$sMediaPath;

}

//Media isn't cached or it's deprecated
if($this->hasToCache($sMediaPath,$sCacheMediaPath)){
Expand Down
2 changes: 0 additions & 2 deletions tests/AssetsBundleTest/Service/ServiceProdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ public function testRenderTestHugeAssets(){
protected function assertAssetCacheContent(array $aAssetsFiles){
$sCacheExpectedPath = __DIR__.'/../_files/prod-cache-expected';
foreach($aAssetsFiles as $sAssetFile){
file_put_contents($sCacheExpectedPath.DIRECTORY_SEPARATOR.$sAssetFile,
str_replace(PHP_EOL,"\n",file_get_contents($this->service->getOptions()->getCachePath().$sAssetFile)));
$this->assertStringEqualsFile(
$sCacheExpectedPath.DIRECTORY_SEPARATOR.$sAssetFile,
str_replace(PHP_EOL,"\n",file_get_contents($this->service->getOptions()->getCachePath().$sAssetFile))
Expand Down

Large diffs are not rendered by default.

181 changes: 94 additions & 87 deletions tests/_report/Module.php.html

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions tests/_report/index.dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dashboard for C:\Users\emilien\workspace-zf2\zf2-assets-bundle</title>
<title>Dashboard for /var/www/home/escalle/public/zf2-assets-bundle</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
Expand All @@ -17,7 +17,7 @@
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li><a href="index.html">C:\Users\emilien\workspace-zf2\zf2-assets-bundle</a></li>
<li><a href="index.html">/var/www/home/escalle/public/zf2-assets-bundle</a></li>
<li class="active">(Dashboard)</li>

</ul>
Expand Down Expand Up @@ -52,7 +52,7 @@ <h2>Least Tested Methods</h2>
</div>
<footer>
<p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.12</a> using <a href="http://www.php.net/" target="_top">PHP 5.4.13</a> and <a href="http://phpunit.de/">PHPUnit 3.7.24</a> at Tue Aug 20 11:24:20 CEST 2013.</small>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.3.3-7+squeeze14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.27</a> at Thu Nov 7 11:52:23 CET 2013.</small>
</p>
</footer>
</div>
Expand All @@ -74,11 +74,13 @@ <h2>Least Tested Methods</h2>
labels: {style: {fontSize: '8px'}},
categories: [
'0%','0-10%','10-20%','20-30%','30-40%','40-50%','50-60%','60-70%','70-80%','80-90%','90-100%','100%'
]
],
min: 0
},
yAxis: {
title: '',
labels: {style: {fontSize: '8px'}},
min: 0
},
series: [{
data: [0,0,0,0,0,0,0,0,0,0,0,28]
Expand All @@ -96,18 +98,20 @@ <h2>Least Tested Methods</h2>
xAxis: {
title: {text: 'Code Coverage (in percent)'},
labels: {enabled: true},
min: 0
},
yAxis: {
title: {text: 'Cyclomatic Complexity'},
labels: {enabled: true},
min: 0
},
tooltip: {
formatter: function() {
return this.point.config[2];
}
},
series: [{
data: [[100,16,"<a href=\"Module.php.html#3\">Module<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Controller_ToolsController.php.html#3\">ToolsController<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_CssFilterFactory.php.html#3\">CssFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_GifFilterFactory.php.html#3\">GifFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_JpegFilterFactory.php.html#3\">JpegFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_JsFilterFactory.php.html#3\">JsFilterFactory<\/a>"],[100,2,"<a href=\"src_AssetsBundle_Factory_Filter_LessFilterFactory.php.html#3\">LessFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_PngFilterFactory.php.html#3\">PngFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_JsCustomRendererFactory.php.html#3\">JsCustomRendererFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_JsCustomStrategyFactory.php.html#3\">JsCustomStrategyFactory<\/a>"],[100,16,"<a href=\"src_AssetsBundle_Factory_ServiceFactory.php.html#3\">ServiceFactory<\/a>"],[100,14,"<a href=\"src_AssetsBundle_Mvc_Controller_AbstractActionController.php.html#3\">AbstractActionController<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_AssetsFilterManager.php.html#3\">AssetsFilterManager<\/a>"],[100,15,"<a href=\"src_AssetsBundle_Service_Filter_AbstractImageFilter.php.html#3\">AbstractImageFilter<\/a>"],[100,5,"<a href=\"src_AssetsBundle_Service_Filter_CssFilter.php.html#3\">CssFilter<\/a>"],[100,9,"<a href=\"src_AssetsBundle_Service_Filter_GifFilter.php.html#3\">GifFilter<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Service_Filter_JpegFilter.php.html#3\">JpegFilter<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_Filter_JsFilter.php.html#3\">JsFilter<\/a>"],[100,19,"<a href=\"src_AssetsBundle_Service_Filter_LessFilter.php.html#3\">LessFilter<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Service_Filter_PngFilter.php.html#3\">PngFilter<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_RenderStrategyManager.php.html#3\">RenderStrategyManager<\/a>"],[100,240,"<a href=\"src_AssetsBundle_Service_Service.php.html#3\">Service<\/a>"],[100,77,"<a href=\"src_AssetsBundle_Service_ServiceOptions.php.html#3\">ServiceOptions<\/a>"],[100,15,"<a href=\"src_AssetsBundle_View_Renderer_JsCustomRenderer.php.html#3\">JsCustomRenderer<\/a>"],[100,4,"<a href=\"src_AssetsBundle_View_Strategy_AbstractStrategy.php.html#3\">AbstractStrategy<\/a>"],[100,23,"<a href=\"src_AssetsBundle_View_Strategy_JsCustomStrategy.php.html#3\">JsCustomStrategy<\/a>"],[100,0,"<a href=\"src_AssetsBundle_View_Strategy_NoneStrategy.php.html#3\">NoneStrategy<\/a>"],[100,5,"<a href=\"src_AssetsBundle_View_Strategy_ViewHelperStrategy.php.html#3\">ViewHelperStrategy<\/a>"]],
data: [[100,18,"<a href=\"Module.php.html#3\">Module<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Controller_ToolsController.php.html#3\">ToolsController<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_CssFilterFactory.php.html#3\">CssFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_GifFilterFactory.php.html#3\">GifFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_JpegFilterFactory.php.html#3\">JpegFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_JsFilterFactory.php.html#3\">JsFilterFactory<\/a>"],[100,2,"<a href=\"src_AssetsBundle_Factory_Filter_LessFilterFactory.php.html#3\">LessFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_Filter_PngFilterFactory.php.html#3\">PngFilterFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_JsCustomRendererFactory.php.html#3\">JsCustomRendererFactory<\/a>"],[100,1,"<a href=\"src_AssetsBundle_Factory_JsCustomStrategyFactory.php.html#3\">JsCustomStrategyFactory<\/a>"],[100,16,"<a href=\"src_AssetsBundle_Factory_ServiceFactory.php.html#3\">ServiceFactory<\/a>"],[100,14,"<a href=\"src_AssetsBundle_Mvc_Controller_AbstractActionController.php.html#3\">AbstractActionController<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_AssetsFilterManager.php.html#3\">AssetsFilterManager<\/a>"],[100,15,"<a href=\"src_AssetsBundle_Service_Filter_AbstractImageFilter.php.html#3\">AbstractImageFilter<\/a>"],[100,5,"<a href=\"src_AssetsBundle_Service_Filter_CssFilter.php.html#3\">CssFilter<\/a>"],[100,9,"<a href=\"src_AssetsBundle_Service_Filter_GifFilter.php.html#3\">GifFilter<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Service_Filter_JpegFilter.php.html#3\">JpegFilter<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_Filter_JsFilter.php.html#3\">JsFilter<\/a>"],[100,19,"<a href=\"src_AssetsBundle_Service_Filter_LessFilter.php.html#3\">LessFilter<\/a>"],[100,10,"<a href=\"src_AssetsBundle_Service_Filter_PngFilter.php.html#3\">PngFilter<\/a>"],[100,4,"<a href=\"src_AssetsBundle_Service_RenderStrategyManager.php.html#3\">RenderStrategyManager<\/a>"],[100,241,"<a href=\"src_AssetsBundle_Service_Service.php.html#3\">Service<\/a>"],[100,77,"<a href=\"src_AssetsBundle_Service_ServiceOptions.php.html#3\">ServiceOptions<\/a>"],[100,15,"<a href=\"src_AssetsBundle_View_Renderer_JsCustomRenderer.php.html#3\">JsCustomRenderer<\/a>"],[100,4,"<a href=\"src_AssetsBundle_View_Strategy_AbstractStrategy.php.html#3\">AbstractStrategy<\/a>"],[100,23,"<a href=\"src_AssetsBundle_View_Strategy_JsCustomStrategy.php.html#3\">JsCustomStrategy<\/a>"],[100,0,"<a href=\"src_AssetsBundle_View_Strategy_NoneStrategy.php.html#3\">NoneStrategy<\/a>"],[100,5,"<a href=\"src_AssetsBundle_View_Strategy_ViewHelperStrategy.php.html#3\">ViewHelperStrategy<\/a>"]],
marker: {
symbol: 'diamond'
}
Expand Down
12 changes: 6 additions & 6 deletions tests/_report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Code Coverage for C:\Users\emilien\workspace-zf2\zf2-assets-bundle</title>
<title>Code Coverage for /var/www/home/escalle/public/zf2-assets-bundle</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
Expand All @@ -17,7 +17,7 @@
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li class="active">C:\Users\emilien\workspace-zf2\zf2-assets-bundle</li>
<li class="active">/var/www/home/escalle/public/zf2-assets-bundle</li>
<li>(<a href="index.dashboard.html">Dashboard</a>)</li>

</ul>
Expand Down Expand Up @@ -47,7 +47,7 @@
</div>
</td>
<td class="success small"><div align="right">100.00%</div></td>
<td class="success small"><div align="right">860&nbsp;/&nbsp;860</div></td>
<td class="success small"><div align="right">867&nbsp;/&nbsp;867</div></td>
<td class="success big"> <div class="progress progress-success" style="width: 100px;">
<div class="bar" style="width: 100.00%;"></div>
</div>
Expand All @@ -69,7 +69,7 @@
</div>
</td>
<td class="success small"><div align="right">100.00%</div></td>
<td class="success small"><div align="right">818&nbsp;/&nbsp;818</div></td>
<td class="success small"><div align="right">821&nbsp;/&nbsp;821</div></td>
<td class="success big"> <div class="progress progress-success" style="width: 100px;">
<div class="bar" style="width: 100.00%;"></div>
</div>
Expand All @@ -91,7 +91,7 @@
</div>
</td>
<td class="success small"><div align="right">100.00%</div></td>
<td class="success small"><div align="right">42&nbsp;/&nbsp;42</div></td>
<td class="success small"><div align="right">46&nbsp;/&nbsp;46</div></td>
<td class="success big"> <div class="progress progress-success" style="width: 100px;">
<div class="bar" style="width: 100.00%;"></div>
</div>
Expand All @@ -117,7 +117,7 @@ <h4>Legend</h4>
<span class="success"><strong>High</strong>: 70% to 100%</span>
</p>
<p>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.12</a> using <a href="http://www.php.net/" target="_top">PHP 5.4.13</a> and <a href="http://phpunit.de/">PHPUnit 3.7.24</a> at Tue Aug 20 11:24:20 CEST 2013.</small>
<small>Generated by <a href="http://github.com/sebastianbergmann/php-code-coverage" target="_top">PHP_CodeCoverage 1.2.13</a> using <a href="http://www.php.net/" target="_top">PHP 5.3.3-7+squeeze14</a> and <a href="http://phpunit.de/">PHPUnit 3.7.27</a> at Thu Nov 7 11:52:23 CET 2013.</small>
</p>
</footer>
</div>
Expand Down
Loading

0 comments on commit 1900bd9

Please sign in to comment.