public function newInfoView() { $extensions = PhabricatorGuidanceEngineExtension::getAllExtensions(); $context = $this->getGuidanceContext(); $keep = array(); foreach ($extensions as $key => $extension) { if (!$extension->canGenerateGuidance($context)) { continue; } $keep[$key] = id(clone $extension); } $guidance_map = array(); foreach ($keep as $extension) { $guidance_list = $extension->generateGuidance($context); foreach ($guidance_list as $guidance) { $key = $guidance->getKey(); if (isset($guidance_map[$key])) { throw new Exception(pht('Two guidance extensions generated guidance with the same ' . 'key ("%s"). Each piece of guidance must have a unique key.', $key)); } $guidance_map[$key] = $guidance; } } foreach ($keep as $extension) { $guidance_map = $extension->didGenerateGuidance($context, $guidance_map); } if (!$guidance_map) { return null; } $guidance_map = msortv($guidance_map, 'getSortVector'); $severity = PhabricatorGuidanceMessage::SEVERITY_NOTICE; $strength = null; foreach ($guidance_map as $guidance) { if ($strength !== null) { if ($guidance->getSeverityStrength() <= $strength) { continue; } } $strength = $guidance->getSeverityStrength(); $severity = $guidance->getSeverity(); } $severity_map = array(PhabricatorGuidanceMessage::SEVERITY_NOTICE => PHUIInfoView::SEVERITY_NOTICE, PhabricatorGuidanceMessage::SEVERITY_WARNING => PHUIInfoView::SEVERITY_WARNING); $messages = mpull($guidance_map, 'getMessage', 'getKey'); return id(new PHUIInfoView())->setViewer($this->getViewer())->setSeverity(idx($severity_map, $severity, $severity))->setErrors($messages); }
private function renderPanels() { $panels = $this->panels; $panels = msortv($panels, 'getOrderVector'); return $panels; }
public final function buildEditEngineCommentView($object) { $config = $this->loadDefaultEditConfiguration(); if (!$config) { // TODO: This just nukes the entire comment form if you don't have access // to any edit forms. We might want to tailor this UX a bit. return id(new PhabricatorApplicationTransactionCommentView())->setNoPermission(true); } $viewer = $this->getViewer(); $object_phid = $object->getPHID(); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); if ($is_serious) { $header_text = $this->getCommentViewSeriousHeaderText($object); $button_text = $this->getCommentViewSeriousButtonText($object); } else { $header_text = $this->getCommentViewHeaderText($object); $button_text = $this->getCommentViewButtonText($object); } $comment_uri = $this->getEditURI($object, 'comment/'); $view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($object_phid)->setHeaderText($header_text)->setAction($comment_uri)->setSubmitButtonName($button_text); $draft = PhabricatorVersionedDraft::loadDraft($object_phid, $viewer->getPHID()); if ($draft) { $view->setVersionedDraft($draft); } $view->setCurrentVersion($this->loadDraftVersion($object)); $fields = $this->buildEditFields($object); $comment_actions = array(); foreach ($fields as $field) { if (!$field->shouldGenerateTransactionsFromComment()) { continue; } $comment_action = $field->getCommentAction(); if (!$comment_action) { continue; } $key = $comment_action->getKey(); // TODO: Validate these better. $comment_actions[$key] = $comment_action; } $comment_actions = msortv($comment_actions, 'getSortVector'); $view->setCommentActions($comment_actions); return $view; }
protected function buildCustomEditFields($object) { $viewer = $this->getViewer(); $settings = PhabricatorSetting::getAllEnabledSettings($viewer); foreach ($settings as $key => $setting) { $setting = clone $setting; $setting->setViewer($viewer); $settings[$key] = $setting; } $settings = msortv($settings, 'getSettingOrderVector'); $fields = array(); foreach ($settings as $setting) { foreach ($setting->newCustomEditFields($object) as $field) { $fields[] = $field; } } return $fields; }
public static final function getAllPanels() { $panels = id(new PhutilClassMapQuery())->setAncestorClass(__CLASS__)->setUniqueMethod('getPanelKey')->execute(); return msortv($panels, 'getPanelOrderVector'); }