Changeset View
Changeset View
Standalone View
Standalone View
src/view/layout/PhabricatorPropertyListView.php
| <?php | <?php | ||||
| final class PhabricatorPropertyListView extends AphrontView { | final class PhabricatorPropertyListView extends AphrontView { | ||||
| private $parts = array(); | private $parts = array(); | ||||
| private $hasKeyboardShortcuts; | private $hasKeyboardShortcuts; | ||||
| private $object; | |||||
| private $invokedWillRenderEvent; | |||||
| protected function canAppendChild() { | protected function canAppendChild() { | ||||
| return false; | return false; | ||||
| } | } | ||||
| public function setObject($object) { | |||||
| $this->object = $object; | |||||
| return $this; | |||||
| } | |||||
| public function setHasKeyboardShortcuts($has_keyboard_shortcuts) { | public function setHasKeyboardShortcuts($has_keyboard_shortcuts) { | ||||
| $this->hasKeyboardShortcuts = $has_keyboard_shortcuts; | $this->hasKeyboardShortcuts = $has_keyboard_shortcuts; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function addProperty($key, $value) { | public function addProperty($key, $value) { | ||||
| $current = array_pop($this->parts); | $current = array_pop($this->parts); | ||||
| Show All 27 Lines | final class PhabricatorPropertyListView extends AphrontView { | ||||
| public function addTextContent($content) { | public function addTextContent($content) { | ||||
| $this->parts[] = array( | $this->parts[] = array( | ||||
| 'type' => 'text', | 'type' => 'text', | ||||
| 'content' => $content, | 'content' => $content, | ||||
| ); | ); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function invokeWillRenderEvent() { | |||||
| if ($this->object && $this->getUser() && !$this->invokedWillRenderEvent) { | |||||
| $event = new PhabricatorEvent( | |||||
| PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES, | |||||
| array( | |||||
| 'object' => $this->object, | |||||
| 'view' => $this, | |||||
| )); | |||||
| $event->setUser($this->getUser()); | |||||
| PhutilEventEngine::dispatchEvent($event); | |||||
| } | |||||
| $this->invokedWillRenderEvent = true; | |||||
| } | |||||
| public function render() { | public function render() { | ||||
| $this->invokeWillRenderEvent(); | |||||
| require_celerity_resource('phabricator-property-list-view-css'); | require_celerity_resource('phabricator-property-list-view-css'); | ||||
| $items = array(); | $items = array(); | ||||
| foreach ($this->parts as $part) { | foreach ($this->parts as $part) { | ||||
| $type = $part['type']; | $type = $part['type']; | ||||
| switch ($type) { | switch ($type) { | ||||
| case 'property': | case 'property': | ||||
| $items[] = $this->renderPropertyPart($part); | $items[] = $this->renderPropertyPart($part); | ||||
| ▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines | |||||