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;
|
2013-07-12 20:39:47 +02:00
|
|
|
private $objectURI;
|
2013-04-09 21:42:03 +02:00
|
|
|
private $id = null;
|
2012-08-24 22:19:47 +02:00
|
|
|
|
|
|
|
public function setObject(PhabricatorLiskDAO $object) {
|
|
|
|
$this->object = $object;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-07-12 20:39:47 +02:00
|
|
|
public function setObjectURI($uri) {
|
|
|
|
$this->objectURI = $uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function addAction(PhabricatorActionView $view) {
|
|
|
|
$this->actions[] = $view;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-04-09 21:42:03 +02:00
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-08-15 19:45:06 +02:00
|
|
|
public function render() {
|
2012-08-24 22:19:47 +02:00
|
|
|
if (!$this->user) {
|
2014-06-09 20:36:49 +02: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-10-05 22:12:31 +02:00
|
|
|
if (!$actions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2013-07-12 20:39:47 +02:00
|
|
|
foreach ($actions as $action) {
|
|
|
|
$action->setObjectURI($this->objectURI);
|
|
|
|
$action->setUser($this->user);
|
|
|
|
}
|
|
|
|
|
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',
|
2014-10-07 15:01:04 +02:00
|
|
|
'id' => $this->id,
|
2012-08-15 19:45:06 +02:00
|
|
|
),
|
2013-03-09 22:52:41 +01:00
|
|
|
$actions);
|
2012-08-15 19:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|