Path: blob/master/src/applications/dashboard/install/PhabricatorDashboardInstallWorkflow.php
12242 views
<?php12abstract class PhabricatorDashboardInstallWorkflow3extends Phobject {45private $request;6private $viewer;7private $dashboard;8private $mode;910final public function setViewer(PhabricatorUser $viewer) {11$this->viewer = $viewer;12return $this;13}1415final public function getViewer() {16return $this->viewer;17}1819final public function setDashboard(PhabricatorDashboard $dashboard) {20$this->dashboard = $dashboard;21return $this;22}2324final public function getDashboard() {25return $this->dashboard;26}2728final public function setMode($mode) {29$this->mode = $mode;30return $this;31}3233final public function getMode() {34return $this->mode;35}3637final public function setRequest(AphrontRequest $request) {38$this->request = $request;39return $this;40}4142final public function getRequest() {43return $this->request;44}4546final public function getWorkflowKey() {47return $this->getPhobjectClassConstant('WORKFLOWKEY', 32);48}4950final public static function getAllWorkflows() {51return id(new PhutilClassMapQuery())52->setAncestorClass(__CLASS__)53->setUniqueMethod('getWorkflowKey')54->setSortMethod('getOrder')55->execute();56}5758final public function getWorkflowMenuItem() {59return $this->newWorkflowMenuItem();60}6162abstract public function getOrder();63abstract protected function newWorkflowMenuItem();6465final protected function newMenuItem() {66return id(new PHUIObjectItemView())67->setClickable(true);68}6970abstract public function handleRequest(AphrontRequest $request);7172final protected function newDialog() {73$dashboard = $this->getDashboard();7475return id(new AphrontDialogView())76->setViewer($this->getViewer())77->setWidth(AphrontDialogView::WIDTH_FORM)78->addCancelButton($dashboard->getURI());79}8081final protected function newMenuFromItemMap(array $map) {82$viewer = $this->getViewer();83$dashboard = $this->getDashboard();8485$menu = id(new PHUIObjectItemListView())86->setViewer($viewer)87->setFlush(true)88->setBig(true);8990foreach ($map as $key => $item) {91$item->setHref(92urisprintf(93'/dashboard/install/%d/%s/%s/',94$dashboard->getID(),95$this->getWorkflowKey(),96$key));9798$menu->addItem($item);99}100101return $menu;102}103104abstract protected function newProfileEngine();105106final protected function installDashboard($profile_object, $custom_phid) {107$dashboard = $this->getDashboard();108$engine = $this->newProfileEngine()109->setProfileObject($profile_object);110111$request = $this->getRequest();112$viewer = $this->getViewer();113114$config = PhabricatorProfileMenuItemConfiguration::initializeNewItem(115$profile_object,116new PhabricatorDashboardProfileMenuItem(),117$custom_phid);118119$config->setMenuItemProperty('dashboardPHID', $dashboard->getPHID());120121$xactions = array();122123$editor = id(new PhabricatorProfileMenuEditor())124->setActor($viewer)125->setContinueOnNoEffect(true)126->setContinueOnMissingFields(true)127->setContentSourceFromRequest($request);128129$editor->applyTransactions($config, $xactions);130131$done_uri = $engine->getItemURI(urisprintf('view/%d/', $config->getID()));132133return id(new AphrontRedirectResponse())134->setURI($done_uri);135}136137final protected function getDashboardDisplayName() {138$dashboard = $this->getDashboard();139return phutil_tag('strong', array(), $dashboard->getName());140}141142}143144145