Changeset View
Changeset View
Standalone View
Standalone View
src/applications/celerity/CelerityStaticResourceResponse.php
Show All 9 Lines | final class CelerityStaticResourceResponse extends Phobject { | ||||
private $symbols = array(); | private $symbols = array(); | ||||
private $needsResolve = true; | private $needsResolve = true; | ||||
private $resolved; | private $resolved; | ||||
private $packaged; | private $packaged; | ||||
private $metadata = array(); | private $metadata = array(); | ||||
private $metadataBlock = 0; | private $metadataBlock = 0; | ||||
private $behaviors = array(); | private $behaviors = array(); | ||||
private $hasRendered = array(); | private $hasRendered = array(); | ||||
private $postprocessorKey; | |||||
joshuaspence: Maybe name this `$postprocessor` for consistency with `CelerityResourceTransformer` | |||||
public function __construct() { | public function __construct() { | ||||
if (isset($_REQUEST['__metablock__'])) { | if (isset($_REQUEST['__metablock__'])) { | ||||
$this->metadataBlock = (int)$_REQUEST['__metablock__']; | $this->metadataBlock = (int)$_REQUEST['__metablock__']; | ||||
} | } | ||||
} | } | ||||
public function addMetadata($metadata) { | public function addMetadata($metadata) { | ||||
$id = count($this->metadata); | $id = count($this->metadata); | ||||
$this->metadata[$id] = $metadata; | $this->metadata[$id] = $metadata; | ||||
return $this->metadataBlock.'_'.$id; | return $this->metadataBlock.'_'.$id; | ||||
} | } | ||||
public function getMetadataBlock() { | public function getMetadataBlock() { | ||||
return $this->metadataBlock; | return $this->metadataBlock; | ||||
} | } | ||||
public function setPostprocessorKey($postprocessor_key) { | |||||
Not Done Inline ActionsAs above, I feel that this would be more correctly named setPostprocessorKey joshuaspence: As above, I feel that this would be more correctly named `setPostprocessorKey` | |||||
$this->postprocessorKey = $postprocessor_key; | |||||
return $this; | |||||
} | |||||
public function getPostprocessorKey() { | |||||
return $this->postprocessorKey; | |||||
} | |||||
Not Done Inline ActionsAs above. joshuaspence: As above. | |||||
/** | /** | ||||
* Register a behavior for initialization. | * Register a behavior for initialization. | ||||
* | * | ||||
Not Done Inline ActionsYou maybe got a bit carried away here :P joshuaspence: You maybe got a bit carried away here :P | |||||
* NOTE: If `$config` is empty, a behavior will execute only once even if it | * NOTE: If `$config` is empty, a behavior will execute only once even if it | ||||
* is initialized multiple times. If `$config` is nonempty, the behavior will | * is initialized multiple times. If `$config` is nonempty, the behavior will | ||||
* be invoked once for each configuration. | * be invoked once for each configuration. | ||||
*/ | */ | ||||
public function initBehavior( | public function initBehavior( | ||||
$behavior, | $behavior, | ||||
array $config = array(), | array $config = array(), | ||||
$source_name = null) { | $source_name = null) { | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | final class CelerityStaticResourceResponse extends Phobject { | ||||
public function getURI( | public function getURI( | ||||
CelerityResourceMap $map, | CelerityResourceMap $map, | ||||
$name, | $name, | ||||
$use_primary_domain = false) { | $use_primary_domain = false) { | ||||
$uri = $map->getURIForName($name); | $uri = $map->getURIForName($name); | ||||
// If we have a postprocessor selected, add it to the URI. | |||||
$postprocessor_key = $this->getPostprocessorKey(); | |||||
if ($postprocessor_key) { | |||||
$uri = preg_replace('@^/res/@', '/res/'.$postprocessor_key.'X/', $uri); | |||||
} | |||||
// In developer mode, we dump file modification times into the URI. When a | // In developer mode, we dump file modification times into the URI. When a | ||||
// page is reloaded in the browser, any resources brought in by Ajax calls | // page is reloaded in the browser, any resources brought in by Ajax calls | ||||
// do not trigger revalidation, so without this it's very difficult to get | // do not trigger revalidation, so without this it's very difficult to get | ||||
// changes to Ajaxed-in CSS to work (you must clear your cache or rerun | // changes to Ajaxed-in CSS to work (you must clear your cache or rerun | ||||
// the map script). In production, we can assume the map script gets run | // the map script). In production, we can assume the map script gets run | ||||
// after changes, and safely skip this. | // after changes, and safely skip this. | ||||
if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) { | if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) { | ||||
$mtime = $map->getModifiedTimeForName($name); | $mtime = $map->getModifiedTimeForName($name); | ||||
Show All 11 Lines |
Maybe name this $postprocessor for consistency with CelerityResourceTransformer