2012-08-15 10:45:06 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorActionListView extends AphrontView {
|
|
|
|
|
|
|
|
private $actions = array();
|
2012-08-24 13:19:47 -07:00
|
|
|
private $object;
|
2013-04-09 12:42:03 -07:00
|
|
|
private $id = null;
|
2012-08-24 13:19:47 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-04-09 12:42:03 -07:00
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 10:45:06 -07:00
|
|
|
public function render() {
|
2012-08-24 13:19:47 -07:00
|
|
|
if (!$this->user) {
|
2013-03-01 15:37:32 -08:00
|
|
|
throw new Exception(pht("Call setUser() before render()!"));
|
2012-08-24 13:19:47 -07: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 10:45:06 -07:00
|
|
|
|
2012-10-05 13:12:31 -07:00
|
|
|
if (!$actions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-08-24 13:19:47 -07:00
|
|
|
require_celerity_resource('phabricator-action-list-view-css');
|
2013-01-25 12:57:47 -08:00
|
|
|
|
|
|
|
return phutil_tag(
|
2012-08-15 10:45:06 -07:00
|
|
|
'ul',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-action-list-view',
|
2013-04-09 12:42:03 -07:00
|
|
|
'id' => $this->id
|
2012-08-15 10:45:06 -07:00
|
|
|
),
|
2013-03-09 13:52:41 -08:00
|
|
|
$actions);
|
2012-08-15 10:45:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|