Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
d3beeb7d
Commit
d3beeb7d
authored
May 16, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Usage of "yii\console\controllers\AssetController::actionCompress()" has been clarified.
parent
06752ae9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
24 deletions
+20
-24
AssetControllerTest.php
...nit/framework/console/controllers/AssetControllerTest.php
+2
-15
AssetController.php
yii/console/controllers/AssetController.php
+18
-9
No files found.
tests/unit/framework/console/controllers/AssetControllerTest.php
View file @
d3beeb7d
...
@@ -130,20 +130,6 @@ class AssetControllerTest extends TestCase
...
@@ -130,20 +130,6 @@ class AssetControllerTest extends TestCase
}
}
/**
/**
* Creates test bundles configuration file.
* @param string $fileName output filename.
* @param array[] $bundles asset bundles config.
* @throws Exception on failure.
*/
protected
function
createBundleFile
(
$fileName
,
array
$bundles
)
{
$content
=
'<?php return '
.
var_export
(
$this
->
createBundleConfig
(
$bundles
),
true
)
.
';'
;
if
(
file_put_contents
(
$fileName
,
$content
)
<=
0
)
{
throw
new
\Exception
(
"Unable to create file '
{
$fileName
}
'!"
);
}
}
/**
* Creates test compress config file.
* Creates test compress config file.
* @param string $fileName output file name.
* @param string $fileName output file name.
* @param array[] $bundles asset bundles config.
* @param array[] $bundles asset bundles config.
...
@@ -224,7 +210,6 @@ class AssetControllerTest extends TestCase
...
@@ -224,7 +210,6 @@ class AssetControllerTest extends TestCase
),
),
);;
);;
$bundleFile
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'bundle.php'
;
$bundleFile
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'bundle.php'
;
$this
->
createBundleFile
(
$bundleFile
,
$bundles
);
$configFile
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'config.php'
;
$configFile
=
$this
->
testFilePath
.
DIRECTORY_SEPARATOR
.
'config.php'
;
$this
->
createCompressConfigFile
(
$configFile
,
$bundles
);
$this
->
createCompressConfigFile
(
$configFile
,
$bundles
);
...
@@ -233,6 +218,8 @@ class AssetControllerTest extends TestCase
...
@@ -233,6 +218,8 @@ class AssetControllerTest extends TestCase
$this
->
runAssetControllerAction
(
'compress'
,
array
(
$configFile
,
$bundleFile
));
$this
->
runAssetControllerAction
(
'compress'
,
array
(
$configFile
,
$bundleFile
));
// Then :
// Then :
$this
->
assertTrue
(
file_exists
(
$bundleFile
),
'Unable to create output bundle file!'
);
$compressedCssFileName
=
$this
->
testAssetsBasePath
.
DIRECTORY_SEPARATOR
.
'all.css'
;
$compressedCssFileName
=
$this
->
testAssetsBasePath
.
DIRECTORY_SEPARATOR
.
'all.css'
;
$this
->
assertTrue
(
file_exists
(
$compressedCssFileName
),
'Unable to compress CSS files!'
);
$this
->
assertTrue
(
file_exists
(
$compressedCssFileName
),
'Unable to compress CSS files!'
);
$compressedJsFileName
=
$this
->
testAssetsBasePath
.
DIRECTORY_SEPARATOR
.
'all.js'
;
$compressedJsFileName
=
$this
->
testAssetsBasePath
.
DIRECTORY_SEPARATOR
.
'all.js'
;
...
...
yii/console/controllers/AssetController.php
View file @
d3beeb7d
...
@@ -77,8 +77,10 @@ class AssetController extends Controller
...
@@ -77,8 +77,10 @@ class AssetController extends Controller
/**
/**
* Combines and compresses the asset files according to the given configuration.
* Combines and compresses the asset files according to the given configuration.
* During the process new asset bundle configuration file will be created.
* You should replace your original asset bundle configuration with this file in order to use compressed files.
* @param string $configFile configuration file name.
* @param string $configFile configuration file name.
* @param string $bundleFile
* @param string $bundleFile
output asset bundles configuration file name.
*/
*/
public
function
actionCompress
(
$configFile
,
$bundleFile
)
public
function
actionCompress
(
$configFile
,
$bundleFile
)
{
{
...
@@ -124,10 +126,10 @@ class AssetController extends Controller
...
@@ -124,10 +126,10 @@ class AssetController extends Controller
}
}
/**
/**
* Creates full list of asset bundles.
* Creates full list of
source
asset bundles.
* @param array[] $bundles list of asset bundle configurations.
* @param array[] $bundles list of asset bundle configurations.
* @param array $extensions list of the extension paths.
* @param array $extensions list of the extension paths.
* @return \yii\web\AssetBundle[] list of asset bundles.
* @return \yii\web\AssetBundle[] list of
source
asset bundles.
*/
*/
protected
function
loadBundles
(
$bundles
,
$extensions
)
protected
function
loadBundles
(
$bundles
,
$extensions
)
{
{
...
@@ -152,9 +154,10 @@ class AssetController extends Controller
...
@@ -152,9 +154,10 @@ class AssetController extends Controller
}
}
/**
/**
* @param array $targets
* Creates full list of output asset bundles.
* @param \yii\web\AssetBundle[] $bundles list of asset bundles.
* @param array $targets output asset bundles configuration.
* @return \yii\web\AssetBundle[]
* @param \yii\web\AssetBundle[] $bundles list of source asset bundles.
* @return \yii\web\AssetBundle[] list of output asset bundles.
* @throws \yii\console\Exception on failure.
* @throws \yii\console\Exception on failure.
*/
*/
protected
function
loadTargets
(
$targets
,
$bundles
)
protected
function
loadTargets
(
$targets
,
$bundles
)
...
@@ -260,9 +263,10 @@ class AssetController extends Controller
...
@@ -260,9 +263,10 @@ class AssetController extends Controller
}
}
/**
/**
* @param \yii\web\AssetBundle[] $targets
* Adjust dependencies between asset bundles in the way source bundles begin to depend on output ones.
* @param \yii\web\AssetBundle[] $bundles
* @param \yii\web\AssetBundle[] $targets output asset bundles.
* @return \yii\web\AssetBundle[]
* @param \yii\web\AssetBundle[] $bundles source asset bundles.
* @return \yii\web\AssetBundle[] output asset bundles.
*/
*/
protected
function
adjustDependency
(
$targets
,
$bundles
)
protected
function
adjustDependency
(
$targets
,
$bundles
)
{
{
...
@@ -321,6 +325,11 @@ class AssetController extends Controller
...
@@ -321,6 +325,11 @@ class AssetController extends Controller
}
}
}
}
/**
* Saves new asset bundles configuration.
* @param \yii\web\AssetBundle[] $targets list of asset bundles to be saved.
* @param string $bundleFile output file name.
*/
protected
function
saveTargets
(
$targets
,
$bundleFile
)
protected
function
saveTargets
(
$targets
,
$bundleFile
)
{
{
$array
=
array
();
$array
=
array
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment