Path: blob/master/src/applications/celerity/controller/CelerityPhabricatorResourceController.php
12256 views
<?php12/**3* Delivers CSS and JS resources to the browser. This controller handles all4* `/res/` requests, and manages caching, package construction, and resource5* preprocessing.6*/7final class CelerityPhabricatorResourceController8extends CelerityResourceController {910private $path;11private $hash;12private $library;13private $postprocessorKey;1415public function getCelerityResourceMap() {16return CelerityResourceMap::getNamedInstance($this->library);17}1819public function handleRequest(AphrontRequest $request) {20$this->path = $request->getURIData('path');21$this->hash = $request->getURIData('hash');22$this->library = $request->getURIData('library');23$this->postprocessorKey = $request->getURIData('postprocessor');2425// Check that the resource library exists before trying to serve resources26// from it.27try {28$this->getCelerityResourceMap();29} catch (Exception $ex) {30return new Aphront400Response();31}3233return $this->serveResource(34array(35'path' => $this->path,36'hash' => $this->hash,37));38}3940protected function buildResourceTransformer() {41$developer_on = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');42$should_minify = !$developer_on;4344return id(new CelerityResourceTransformer())45->setMinify($should_minify)46->setPostprocessorKey($this->postprocessorKey)47->setCelerityMap($this->getCelerityResourceMap());48}4950protected function getCacheKey($path) {51return parent::getCacheKey($path.';'.$this->postprocessorKey);52}5354}555657