Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / view / AphrontJavelinView.php
blob7a2954eee377ff37181c13911813a1054a63199b
1 <?php
3 final class AphrontJavelinView extends AphrontView {
4 private static $renderContext = array();
5 private static function peekRenderContext() {
6 return nonempty(end(self::$renderContext), null);
9 private static function popRenderContext() {
10 return array_pop(self::$renderContext);
13 private static function pushRenderContext($token) {
14 self::$renderContext[] = $token;
18 private $name;
19 private $parameters;
20 private $celerityResource;
22 public function render() {
23 $id = celerity_generate_unique_node_id();
24 $placeholder = phutil_tag('span', array('id' => $id));
26 require_celerity_resource($this->getCelerityResource());
28 $render_context = self::peekRenderContext();
29 self::pushRenderContext($id);
31 Javelin::initBehavior('view-placeholder', array(
32 'id' => $id,
33 'view' => $this->getName(),
34 'params' => $this->getParameters(),
35 'children' => phutil_implode_html('', $this->renderChildren()),
36 'trigger_id' => $render_context,
37 ));
39 self::popRenderContext();
41 return $placeholder;
45 protected function getName() {
46 return $this->name;
49 public function setName($template_name) {
50 $this->name = $template_name;
51 return $this;
54 protected function getParameters() {
55 return $this->parameters;
58 public function setParameters($template_parameters) {
59 $this->parameters = $template_parameters;
60 return $this;
63 protected function getCelerityResource() {
64 return $this->celerityResource;
67 public function setCelerityResource($celerity_resource) {
68 $this->celerityResource = $celerity_resource;
69 return $this;