Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93931194
CelerityPhabricatorResourceController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 2, 14:40
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 14:40 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22723514
Attached To
rPH Phabricator
CelerityPhabricatorResourceController.php
View Options
<?php
/**
* Delivers CSS and JS resources to the browser. This controller handles all
* `/res/` requests, and manages caching, package construction, and resource
* preprocessing.
*/
final
class
CelerityPhabricatorResourceController
extends
CelerityResourceController
{
private
$path
;
private
$hash
;
private
$library
;
private
$postprocessorKey
;
public
function
getCelerityResourceMap
()
{
return
CelerityResourceMap
::
getNamedInstance
(
$this
->
library
);
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$this
->
path
=
$request
->
getURIData
(
'path'
);
$this
->
hash
=
$request
->
getURIData
(
'hash'
);
$this
->
library
=
$request
->
getURIData
(
'library'
);
$this
->
postprocessorKey
=
$request
->
getURIData
(
'postprocessor'
);
// Check that the resource library exists before trying to serve resources
// from it.
try
{
$this
->
getCelerityResourceMap
();
}
catch
(
Exception
$ex
)
{
return
new
Aphront400Response
();
}
return
$this
->
serveResource
(
array
(
'path'
=>
$this
->
path
,
'hash'
=>
$this
->
hash
,
));
}
protected
function
buildResourceTransformer
()
{
$minify_on
=
PhabricatorEnv
::
getEnvConfig
(
'celerity.minify'
);
$developer_on
=
PhabricatorEnv
::
getEnvConfig
(
'phabricator.developer-mode'
);
$should_minify
=
(
$minify_on
&&
!
$developer_on
);
return
id
(
new
CelerityResourceTransformer
())
->
setMinify
(
$should_minify
)
->
setPostprocessorKey
(
$this
->
postprocessorKey
)
->
setCelerityMap
(
$this
->
getCelerityResourceMap
());
}
protected
function
getCacheKey
(
$path
)
{
return
parent
::
getCacheKey
(
$path
.
';'
.
$this
->
postprocessorKey
);
}
}
Event Timeline
Log In to Comment