2012-10-17 17:37:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delivers CSS and JS resources to the browser. This controller handles all
|
|
|
|
* ##/res/## requests, and manages caching, package construction, and resource
|
|
|
|
* preprocessing.
|
|
|
|
*
|
|
|
|
* @group celerity
|
|
|
|
*/
|
|
|
|
final class CelerityPhabricatorResourceController
|
|
|
|
extends CelerityResourceController {
|
|
|
|
|
|
|
|
private $path;
|
|
|
|
private $hash;
|
|
|
|
private $package;
|
|
|
|
|
|
|
|
protected function getRootDirectory() {
|
|
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
|
|
return $root.'/webroot/';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->path = $data['path'];
|
|
|
|
$this->hash = $data['hash'];
|
|
|
|
$this->package = !empty($data['package']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$package_hash = null;
|
|
|
|
if ($this->package) {
|
|
|
|
$package_hash = $this->hash;
|
|
|
|
}
|
|
|
|
return $this->serveResource($this->path, $package_hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildResourceTransformer() {
|
|
|
|
$xformer = new CelerityResourceTransformer();
|
2013-02-01 18:34:06 +01:00
|
|
|
$xformer->setMinify(
|
|
|
|
!PhabricatorEnv::getEnvConfig('phabricator.developer-mode') &&
|
|
|
|
PhabricatorEnv::getEnvConfig('celerity.minify'));
|
2012-10-17 17:37:05 +02:00
|
|
|
$xformer->setCelerityMap(CelerityResourceMap::getInstance());
|
|
|
|
return $xformer;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|