2012-08-15 19:45:06 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorActionListView extends AphrontView {
|
|
|
|
|
|
|
|
private $actions = array();
|
2012-08-24 22:19:47 +02:00
|
|
|
private $object;
|
|
|
|
|
|
|
|
public function setObject(PhabricatorLiskDAO $object) {
|
|
|
|
$this->object = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function addAction(PhabricatorActionView $view) {
|
|
|
|
$this->actions[] = $view;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
2012-08-24 22:19:47 +02:00
|
|
|
if (!$this->user) {
|
2013-03-02 00:37:32 +01:00
|
|
|
throw new Exception(pht("Call setUser() before render()!"));
|
2012-08-24 22:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,
|
|
|
|
array(
|
|
|
|
'object' => $this->object,
|
|
|
|
'actions' => $this->actions,
|
|
|
|
));
|
|
|
|
$event->setUser($this->user);
|
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
|
|
|
|
|
|
|
$actions = $event->getValue('actions');
|
2012-08-15 19:45:06 +02:00
|
|
|
|
2012-10-05 22:12:31 +02:00
|
|
|
if (!$actions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-08-24 22:19:47 +02:00
|
|
|
require_celerity_resource('phabricator-action-list-view-css');
|
2013-01-25 21:57:47 +01:00
|
|
|
|
|
|
|
return phutil_tag(
|
2012-08-15 19:45:06 +02:00
|
|
|
'ul',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-list-view',
|
|
|
|
),
|
2013-02-13 23:50:15 +01:00
|
|
|
$this->renderSingleView($actions));
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|