protected function addMerchantCrumb($crumbs, PhortuneMerchant $merchant, $link = true) { $name = $merchant->getName(); $href = null; $crumbs->addTextCrumb(pht('Merchants'), $this->getApplicationURI('merchant/')); if ($link) { $href = $this->getApplicationURI('merchant/' . $merchant->getID() . '/'); $crumbs->addTextCrumb($name, $href); } else { $crumbs->addTextCrumb($name); } }
private function processChooseClassRequest(AphrontRequest $request, PhortuneMerchant $merchant, array $current_map) { $viewer = $request->getUser(); $providers = PhortunePaymentProvider::getAllProviders(); $v_class = null; $errors = array(); if ($request->isFormPost()) { $v_class = $request->getStr('class'); if (!isset($providers[$v_class])) { $errors[] = pht('You must select a valid provider type.'); } } $merchant_id = $merchant->getID(); $cancel_uri = $this->getApplicationURI("merchant/{$merchant_id}/"); if (!$v_class) { $v_class = key($providers); } $panel_classes = id(new AphrontFormRadioButtonControl())->setName('class')->setValue($v_class); $providers = msort($providers, 'getConfigureName'); foreach ($providers as $class => $provider) { $disabled = isset($current_map[$class]); if ($disabled) { $description = phutil_tag('em', array(), pht('This merchant already has a payment account configured ' . 'with this provider.')); } else { $description = $provider->getConfigureDescription(); } $panel_classes->addButton($class, $provider->getConfigureName(), $description, null, $disabled); } $form = id(new AphrontFormView())->setUser($viewer)->addHiddenInput('merchantID', $merchant->getID())->appendRemarkupInstructions(pht('Choose the type of payment provider to add:'))->appendChild($panel_classes)->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue'))->addCancelButton($cancel_uri)); $title = pht('Add Payment Provider'); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($merchant->getName(), $cancel_uri); $crumbs->addTextCrumb($title); $box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form); return $this->buildApplicationPage(array($crumbs, $box), array('title' => $title)); }