Restore highlighting when jumping to transactions using URI anchors
[phabricator/blender.git] / src / view / layout / PhabricatorActionListView.php
blob22e995ab642ace493b3d542f667d47a9063008b2
1 <?php
3 final class PhabricatorActionListView extends AphrontTagView {
5 private $actions = array();
6 private $object;
8 public function setObject(PhabricatorLiskDAO $object) {
9 $this->object = $object;
10 return $this;
13 public function addAction(PhabricatorActionView $view) {
14 $this->actions[] = $view;
15 return $this;
18 protected function getTagName() {
19 if (!$this->actions) {
20 return null;
23 return 'ul';
26 protected function getTagAttributes() {
27 $classes = array();
28 $classes[] = 'phabricator-action-list-view';
29 return array(
30 'class' => implode(' ', $classes),
34 protected function getTagContent() {
35 $viewer = $this->getViewer();
37 $event = new PhabricatorEvent(
38 PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,
39 array(
40 'object' => $this->object,
41 'actions' => $this->actions,
42 ));
43 $event->setUser($viewer);
44 PhutilEventEngine::dispatchEvent($event);
46 $actions = $event->getValue('actions');
47 if (!$actions) {
48 return null;
51 foreach ($actions as $action) {
52 $action->setViewer($viewer);
55 $sort = array();
56 foreach ($actions as $key => $action) {
57 $sort[$key] = id(new PhutilSortVector())
58 ->addInt($action->getOrder());
60 $sort = msortv($sort, 'getSelf');
61 $actions = array_select_keys($actions, array_keys($sort));
63 require_celerity_resource('phabricator-action-list-view-css');
65 $items = array();
66 foreach ($actions as $action) {
67 foreach ($action->getItems() as $item) {
68 $items[] = $item;
72 return $items;
75 public function getDropdownMenuMetadata() {
76 return array(
77 'items' => (string)hsprintf('%s', $this),