2012-08-15 10:45:06 -07:00
|
|
|
<?php
|
|
|
|
|
2017-01-17 12:04:28 -08:00
|
|
|
final class PhabricatorActionListView extends AphrontTagView {
|
2012-08-15 10:45:06 -07:00
|
|
|
|
|
|
|
private $actions = array();
|
2012-08-24 13:19:47 -07:00
|
|
|
private $object;
|
|
|
|
|
|
|
|
public function setObject(PhabricatorLiskDAO $object) {
|
|
|
|
$this->object = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 10:45:06 -07:00
|
|
|
public function addAction(PhabricatorActionView $view) {
|
|
|
|
$this->actions[] = $view;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:04:28 -08:00
|
|
|
protected function getTagName() {
|
|
|
|
return 'ul';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagAttributes() {
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-action-list-view';
|
|
|
|
return array(
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getTagContent() {
|
2016-03-06 06:26:34 -08:00
|
|
|
$viewer = $this->getViewer();
|
2012-08-24 13:19:47 -07:00
|
|
|
|
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,
|
|
|
|
array(
|
|
|
|
'object' => $this->object,
|
|
|
|
'actions' => $this->actions,
|
|
|
|
));
|
2016-03-06 06:26:34 -08:00
|
|
|
$event->setUser($viewer);
|
2012-08-24 13:19:47 -07:00
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
|
|
|
|
|
|
|
$actions = $event->getValue('actions');
|
2012-10-05 13:12:31 -07:00
|
|
|
if (!$actions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-07-12 11:39:47 -07:00
|
|
|
foreach ($actions as $action) {
|
2016-03-06 06:26:34 -08:00
|
|
|
$action->setViewer($viewer);
|
2013-07-12 11:39:47 -07:00
|
|
|
}
|
|
|
|
|
2012-08-24 13:19:47 -07:00
|
|
|
require_celerity_resource('phabricator-action-list-view-css');
|
2013-01-25 12:57:47 -08:00
|
|
|
|
2016-06-20 17:49:38 -07:00
|
|
|
$items = array();
|
|
|
|
foreach ($actions as $action) {
|
|
|
|
foreach ($action->getItems() as $item) {
|
|
|
|
$items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:04:28 -08:00
|
|
|
return $items;
|
2012-08-15 10:45:06 -07:00
|
|
|
}
|
|
|
|
|
2016-06-20 11:49:11 -07:00
|
|
|
public function getDropdownMenuMetadata() {
|
|
|
|
return array(
|
|
|
|
'items' => (string)hsprintf('%s', $this),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-08-15 10:45:06 -07:00
|
|
|
|
|
|
|
}
|