Path: blob/master/src/view/layout/PhabricatorActionListView.php
12241 views
<?php12final class PhabricatorActionListView extends AphrontTagView {34private $actions = array();5private $object;67public function setObject(PhabricatorLiskDAO $object) {8$this->object = $object;9return $this;10}1112public function addAction(PhabricatorActionView $view) {13$this->actions[] = $view;14return $this;15}1617protected function getTagName() {18if (!$this->actions) {19return null;20}2122return 'ul';23}2425protected function getTagAttributes() {26$classes = array();27$classes[] = 'phabricator-action-list-view';28return array(29'class' => implode(' ', $classes),30);31}3233protected function getTagContent() {34$viewer = $this->getViewer();3536$event = new PhabricatorEvent(37PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,38array(39'object' => $this->object,40'actions' => $this->actions,41));42$event->setUser($viewer);43PhutilEventEngine::dispatchEvent($event);4445$actions = $event->getValue('actions');46if (!$actions) {47return null;48}4950foreach ($actions as $action) {51$action->setViewer($viewer);52}5354$sort = array();55foreach ($actions as $key => $action) {56$sort[$key] = id(new PhutilSortVector())57->addInt($action->getOrder());58}59$sort = msortv($sort, 'getSelf');60$actions = array_select_keys($actions, array_keys($sort));6162require_celerity_resource('phabricator-action-list-view-css');6364$items = array();65foreach ($actions as $action) {66foreach ($action->getItems() as $item) {67$items[] = $item;68}69}7071return $items;72}7374public function getDropdownMenuMetadata() {75return array(76'items' => (string)hsprintf('%s', $this),77);78}798081}828384