Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/PhabricatorMarkupEngine.php
Show All 38 Lines | |||||
*/ | */ | ||||
final class PhabricatorMarkupEngine extends Phobject { | final class PhabricatorMarkupEngine extends Phobject { | ||||
private $objects = array(); | private $objects = array(); | ||||
private $viewer; | private $viewer; | ||||
private $contextObject; | private $contextObject; | ||||
private $version = 15; | private $version = 15; | ||||
private $engineCaches = array(); | private $engineCaches = array(); | ||||
private $auxiliaryConfig = array(); | |||||
/* -( Markup Pipeline )---------------------------------------------------- */ | /* -( Markup Pipeline )---------------------------------------------------- */ | ||||
/** | /** | ||||
* Convenience method for pushing a single object through the markup | * Convenience method for pushing a single object through the markup | ||||
* pipeline. | * pipeline. | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | public function process() { | ||||
// Build all the markup engines. We need an engine for each field whether | // Build all the markup engines. We need an engine for each field whether | ||||
// we have a cache or not, since we still need to postprocess the cache. | // we have a cache or not, since we still need to postprocess the cache. | ||||
$engines = array(); | $engines = array(); | ||||
foreach ($objects as $key => $info) { | foreach ($objects as $key => $info) { | ||||
$engines[$key] = $info['object']->newMarkupEngine($info['field']); | $engines[$key] = $info['object']->newMarkupEngine($info['field']); | ||||
$engines[$key]->setConfig('viewer', $this->viewer); | $engines[$key]->setConfig('viewer', $this->viewer); | ||||
$engines[$key]->setConfig('contextObject', $this->contextObject); | $engines[$key]->setConfig('contextObject', $this->contextObject); | ||||
foreach ($this->auxiliaryConfig as $aux_key => $aux_value) { | |||||
$engines[$key]->setConfig($aux_key, $aux_value); | |||||
} | |||||
} | } | ||||
// Load or build the preprocessor caches. | // Load or build the preprocessor caches. | ||||
$blocks = $this->loadPreprocessorCaches($engines, $objects); | $blocks = $this->loadPreprocessorCaches($engines, $objects); | ||||
$blocks = mpull($blocks, 'getCacheData'); | $blocks = mpull($blocks, 'getCacheData'); | ||||
$this->engineCaches = $blocks; | $this->engineCaches = $blocks; | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | /* -( Markup Pipeline )---------------------------------------------------- */ | ||||
* @return this | * @return this | ||||
* @task markup | * @task markup | ||||
*/ | */ | ||||
public function setContextObject($object) { | public function setContextObject($object) { | ||||
$this->contextObject = $object; | $this->contextObject = $object; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setAuxiliaryConfig($key, $value) { | |||||
// TODO: This is gross and should be removed. Avoid use. | |||||
$this->auxiliaryConfig[$key] = $value; | |||||
return $this; | |||||
} | |||||
/* -( Engine Construction )------------------------------------------------ */ | /* -( Engine Construction )------------------------------------------------ */ | ||||
/** | /** | ||||
* @task engine | * @task engine | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 316 Lines • Show Last 20 Lines |