Differential D20733 Diff 49429 src/applications/phortune/controller/merchant/PhortuneMerchantProfileController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/controller/merchant/PhortuneMerchantProfileController.php
<?php | <?php | ||||
abstract class PhortuneMerchantProfileController | abstract class PhortuneMerchantProfileController | ||||
extends PhortuneController { | extends PhortuneMerchantController { | ||||
private $merchant; | |||||
public function setMerchant(PhortuneMerchant $merchant) { | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getMerchant() { | |||||
return $this->merchant; | |||||
} | |||||
public function buildApplicationMenu() { | |||||
return $this->buildSideNavView()->getMenu(); | |||||
} | |||||
protected function buildHeaderView() { | protected function buildHeaderView() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$merchant = $this->getMerchant(); | $merchant = $this->getMerchant(); | ||||
$title = $merchant->getName(); | $title = $merchant->getName(); | ||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setHeader($title) | ->setHeader($title) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setPolicyObject($merchant) | |||||
->setImage($merchant->getProfileImageURI()); | ->setImage($merchant->getProfileImageURI()); | ||||
return $header; | return $header; | ||||
} | } | ||||
protected function buildApplicationCrumbs() { | protected function buildApplicationCrumbs() { | ||||
$merchant = $this->getMerchant(); | |||||
$id = $merchant->getID(); | |||||
$merchant_uri = $this->getApplicationURI("/merchant/{$id}/"); | |||||
$crumbs = parent::buildApplicationCrumbs(); | $crumbs = parent::buildApplicationCrumbs(); | ||||
if ($this->hasMerchant()) { | |||||
$merchant = $this->getMerchant(); | |||||
$merchant_uri = $merchant->getURI(); | |||||
$crumbs->addTextCrumb($merchant->getName(), $merchant_uri); | $crumbs->addTextCrumb($merchant->getName(), $merchant_uri); | ||||
$crumbs->setBorder(true); | } | ||||
return $crumbs; | return $crumbs; | ||||
} | } | ||||
protected function buildSideNavView($filter = null) { | protected function buildSideNavView($filter = null) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$merchant = $this->getMerchant(); | $merchant = $this->getMerchant(); | ||||
$id = $merchant->getID(); | $id = $merchant->getID(); | ||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | $can_edit = PhabricatorPolicyFilter::hasCapability( | ||||
$viewer, | $viewer, | ||||
$merchant, | $merchant, | ||||
PhabricatorPolicyCapability::CAN_EDIT); | PhabricatorPolicyCapability::CAN_EDIT); | ||||
$nav = id(new AphrontSideNavFilterView()) | $nav = id(new AphrontSideNavFilterView()) | ||||
->setBaseURI(new PhutilURI($this->getApplicationURI())); | ->setBaseURI(new PhutilURI($this->getApplicationURI())); | ||||
$nav->addLabel(pht('Merchant')); | $nav->addLabel(pht('Merchant')); | ||||
$nav->addFilter( | $nav->newLink('overview') | ||||
'overview', | ->setName(pht('Overview')) | ||||
pht('Overview'), | ->setHref($merchant->getURI()) | ||||
$this->getApplicationURI("/merchant/{$id}/"), | ->setIcon('fa-building-o'); | ||||
'fa-building-o'); | |||||
$nav->newLink('details') | |||||
if ($can_edit) { | ->setName(pht('Account Details')) | ||||
$nav->addFilter( | ->setHref($merchant->getDetailsURI()) | ||||
'orders', | ->setIcon('fa-address-card-o') | ||||
pht('Orders'), | ->setDisabled(!$can_edit) | ||||
$this->getApplicationURI("merchant/orders/{$id}/"), | ->setWorkflow(!$can_edit); | ||||
'fa-retweet'); | |||||
$nav->addLabel(pht('Payments')); | |||||
$nav->addFilter( | |||||
'subscriptions', | $nav->newLink('providers') | ||||
pht('Subscriptions'), | ->setName(pht('Payment Providers')) | ||||
$this->getApplicationURI("merchant/{$id}/subscription/"), | ->setHref($merchant->getPaymentProvidersURI()) | ||||
'fa-shopping-cart'); | ->setIcon('fa-credit-card') | ||||
->setDisabled(!$can_edit) | |||||
$nav->addFilter( | ->setWorkflow(!$can_edit); | ||||
'managers', | |||||
pht('Managers'), | $nav->newLink('orders') | ||||
$this->getApplicationURI("/merchant/manager/{$id}/"), | ->setName(pht('Orders')) | ||||
'fa-group'); | ->setHref($merchant->getOrdersURI()) | ||||
} | ->setIcon('fa-shopping-bag') | ||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit); | |||||
$nav->newLink('subscriptions') | |||||
->setName(pht('Subscriptions')) | |||||
->setHref($merchant->getSubscriptionsURI()) | |||||
->setIcon('fa-retweet') | |||||
->setDisabled(!$can_edit) | |||||
->setWorkflow(!$can_edit); | |||||
$nav->addLabel(pht('Personnel')); | |||||
$nav->newLink('managers') | |||||
->setName(pht('Managers')) | |||||
->setHref($merchant->getManagersURI()) | |||||
->setIcon('fa-group'); | |||||
$nav->selectFilter($filter); | $nav->selectFilter($filter); | ||||
return $nav; | return $nav; | ||||
} | } | ||||
} | } |