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
1c786edb
Commit
1c786edb
authored
May 16, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Output of "yii\console\controllers\AssetController::actionCompress()" has been made verbose.
parent
c676e92d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
3 deletions
+35
-3
AssetController.php
yii/console/controllers/AssetController.php
+35
-3
No files found.
yii/console/controllers/AssetController.php
View file @
1c786edb
...
@@ -89,13 +89,15 @@ class AssetController extends Controller
...
@@ -89,13 +89,15 @@ class AssetController extends Controller
$targets
=
$this
->
loadTargets
(
$this
->
targets
,
$bundles
);
$targets
=
$this
->
loadTargets
(
$this
->
targets
,
$bundles
);
$this
->
publishBundles
(
$bundles
,
$this
->
assetManager
);
$this
->
publishBundles
(
$bundles
,
$this
->
assetManager
);
$timestamp
=
time
();
$timestamp
=
time
();
foreach
(
$targets
as
$target
)
{
foreach
(
$targets
as
$name
=>
$target
)
{
echo
"Creating output bundle '
{
$name
}
':
\n
"
;
if
(
!
empty
(
$target
->
js
))
{
if
(
!
empty
(
$target
->
js
))
{
$this
->
buildTarget
(
$target
,
'js'
,
$bundles
,
$timestamp
);
$this
->
buildTarget
(
$target
,
'js'
,
$bundles
,
$timestamp
);
}
}
if
(
!
empty
(
$target
->
css
))
{
if
(
!
empty
(
$target
->
css
))
{
$this
->
buildTarget
(
$target
,
'css'
,
$bundles
,
$timestamp
);
$this
->
buildTarget
(
$target
,
'css'
,
$bundles
,
$timestamp
);
}
}
echo
"
\n
"
;
}
}
$targets
=
$this
->
adjustDependency
(
$targets
,
$bundles
);
$targets
=
$this
->
adjustDependency
(
$targets
,
$bundles
);
...
@@ -109,6 +111,8 @@ class AssetController extends Controller
...
@@ -109,6 +111,8 @@ class AssetController extends Controller
*/
*/
protected
function
loadConfiguration
(
$configFile
)
protected
function
loadConfiguration
(
$configFile
)
{
{
echo
"Loading configuration from '
{
$configFile
}
'...
\n
"
;
foreach
(
require
(
$configFile
)
as
$name
=>
$value
)
{
foreach
(
require
(
$configFile
)
as
$name
=>
$value
)
{
if
(
property_exists
(
$this
,
$name
))
{
if
(
property_exists
(
$this
,
$name
))
{
$this
->
$name
=
$value
;
$this
->
$name
=
$value
;
...
@@ -133,6 +137,7 @@ class AssetController extends Controller
...
@@ -133,6 +137,7 @@ class AssetController extends Controller
*/
*/
protected
function
loadBundles
(
$bundles
,
$extensions
)
protected
function
loadBundles
(
$bundles
,
$extensions
)
{
{
echo
"Collecting source bundles information...
\n
"
;
$result
=
array
();
$result
=
array
();
foreach
(
$bundles
as
$name
=>
$bundle
)
{
foreach
(
$bundles
as
$name
=>
$bundle
)
{
$bundle
[
'class'
]
=
'yii\\web\\AssetBundle'
;
$bundle
[
'class'
]
=
'yii\\web\\AssetBundle'
;
...
@@ -221,13 +226,16 @@ class AssetController extends Controller
...
@@ -221,13 +226,16 @@ class AssetController extends Controller
*/
*/
protected
function
publishBundles
(
$bundles
,
$options
)
protected
function
publishBundles
(
$bundles
,
$options
)
{
{
echo
"
\n
Publishing bundles:
\n
"
;
if
(
!
isset
(
$options
[
'class'
]))
{
if
(
!
isset
(
$options
[
'class'
]))
{
$options
[
'class'
]
=
'yii\\web\\AssetManager'
;
$options
[
'class'
]
=
'yii\\web\\AssetManager'
;
}
}
$am
=
Yii
::
createObject
(
$options
);
$am
=
Yii
::
createObject
(
$options
);
foreach
(
$bundles
as
$bundle
)
{
foreach
(
$bundles
as
$
name
=>
$
bundle
)
{
$bundle
->
publish
(
$am
);
$bundle
->
publish
(
$am
);
echo
" '"
.
$name
.
"' published.
\n
"
;
}
}
echo
"
\n
"
;
}
}
/**
/**
...
@@ -270,6 +278,8 @@ class AssetController extends Controller
...
@@ -270,6 +278,8 @@ class AssetController extends Controller
*/
*/
protected
function
adjustDependency
(
$targets
,
$bundles
)
protected
function
adjustDependency
(
$targets
,
$bundles
)
{
{
echo
"Creating new bundle configuration...
\n
"
;
$map
=
array
();
$map
=
array
();
foreach
(
$targets
as
$name
=>
$target
)
{
foreach
(
$targets
as
$name
=>
$target
)
{
foreach
(
$target
->
depends
as
$bundle
)
{
foreach
(
$target
->
depends
as
$bundle
)
{
...
@@ -342,7 +352,7 @@ class AssetController extends Controller
...
@@ -342,7 +352,7 @@ class AssetController extends Controller
}
}
$array
=
var_export
(
$array
,
true
);
$array
=
var_export
(
$array
,
true
);
$version
=
date
(
'Y-m-d H:i:s'
,
time
());
$version
=
date
(
'Y-m-d H:i:s'
,
time
());
file_put_contents
(
$bundleFile
,
<<<EOD
$bytesWritten
=
file_put_contents
(
$bundleFile
,
<<<EOD
<?php
<?php
/**
/**
* This file is generated by the "yiic script" command.
* This file is generated by the "yiic script" command.
...
@@ -352,15 +362,24 @@ class AssetController extends Controller
...
@@ -352,15 +362,24 @@ class AssetController extends Controller
return $array;
return $array;
EOD
EOD
);
);
if
(
$bytesWritten
<=
0
)
{
throw
new
Exception
(
"Unable to write output bundle configuration at '
{
$bundleFile
}
'."
);
}
echo
"Output bundle configuration created at '
{
$bundleFile
}
'.
\n
"
;
}
}
/**
/**
* Compresses given Java Script files and combines them into the single one.
* Compresses given Java Script files and combines them into the single one.
* @param array $inputFiles list of source file names.
* @param array $inputFiles list of source file names.
* @param string $outputFile output file name.
* @param string $outputFile output file name.
* @throws \yii\console\Exception on failure
*/
*/
protected
function
compressJsFiles
(
$inputFiles
,
$outputFile
)
protected
function
compressJsFiles
(
$inputFiles
,
$outputFile
)
{
{
if
(
empty
(
$inputFiles
))
{
return
;
}
echo
" Compressing JavaScript files...
\n
"
;
if
(
is_string
(
$this
->
jsCompressor
))
{
if
(
is_string
(
$this
->
jsCompressor
))
{
$tmpFile
=
$outputFile
.
'.tmp'
;
$tmpFile
=
$outputFile
.
'.tmp'
;
$this
->
combineJsFiles
(
$inputFiles
,
$tmpFile
);
$this
->
combineJsFiles
(
$inputFiles
,
$tmpFile
);
...
@@ -372,15 +391,24 @@ EOD
...
@@ -372,15 +391,24 @@ EOD
}
else
{
}
else
{
$log
=
call_user_func
(
$this
->
jsCompressor
,
$this
,
$inputFiles
,
$outputFile
);
$log
=
call_user_func
(
$this
->
jsCompressor
,
$this
,
$inputFiles
,
$outputFile
);
}
}
if
(
!
file_exists
(
$outputFile
))
{
throw
new
Exception
(
"Unable to compress JavaScript files into '
{
$outputFile
}
'."
);
}
echo
" JavaScript files compressed into '
{
$outputFile
}
'.
\n
"
;
}
}
/**
/**
* Compresses given CSS files and combines them into the single one.
* Compresses given CSS files and combines them into the single one.
* @param array $inputFiles list of source file names.
* @param array $inputFiles list of source file names.
* @param string $outputFile output file name.
* @param string $outputFile output file name.
* @throws \yii\console\Exception on failure
*/
*/
protected
function
compressCssFiles
(
$inputFiles
,
$outputFile
)
protected
function
compressCssFiles
(
$inputFiles
,
$outputFile
)
{
{
if
(
empty
(
$inputFiles
))
{
return
;
}
echo
" Compressing CSS files...
\n
"
;
if
(
is_string
(
$this
->
cssCompressor
))
{
if
(
is_string
(
$this
->
cssCompressor
))
{
$tmpFile
=
$outputFile
.
'.tmp'
;
$tmpFile
=
$outputFile
.
'.tmp'
;
$this
->
combineCssFiles
(
$inputFiles
,
$tmpFile
);
$this
->
combineCssFiles
(
$inputFiles
,
$tmpFile
);
...
@@ -392,6 +420,10 @@ EOD
...
@@ -392,6 +420,10 @@ EOD
}
else
{
}
else
{
$log
=
call_user_func
(
$this
->
cssCompressor
,
$this
,
$inputFiles
,
$outputFile
);
$log
=
call_user_func
(
$this
->
cssCompressor
,
$this
,
$inputFiles
,
$outputFile
);
}
}
if
(
!
file_exists
(
$outputFile
))
{
throw
new
Exception
(
"Unable to compress CSS files into '
{
$outputFile
}
'."
);
}
echo
" CSS files compressed into '
{
$outputFile
}
'.
\n
"
;
}
}
/**
/**
...
...
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