Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76055741
PhortuneProductViewController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 5, 23:33
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Aug 7, 23:33 (2 d)
Engine
blob
Format
Raw Data
Handle
19656151
Attached To
rPH Phabricator
PhortuneProductViewController.php
View Options
<?php
final
class
PhortuneProductViewController
extends
PhortuneController
{
private
$productID
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
productID
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$product
=
id
(
new
PhortuneProductQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
productID
))
->
executeOne
();
if
(!
$product
)
{
return
new
Aphront404Response
();
}
$title
=
pht
(
'Product: %s'
,
$product
->
getProductName
());
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
$product
->
getProductName
());
$account
=
$this
->
loadActiveAccount
(
$user
);
$edit_uri
=
$this
->
getApplicationURI
(
'product/edit/'
.
$product
->
getID
().
'/'
);
$cart_uri
=
$this
->
getApplicationURI
(
$account
->
getID
().
'/buy/'
.
$product
->
getID
().
'/'
);
$actions
=
id
(
new
PhabricatorActionListView
())
->
setUser
(
$user
)
->
setObjectURI
(
$request
->
getRequestURI
())
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Edit Product'
))
->
setHref
(
$edit_uri
)
->
setIcon
(
'edit'
))
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setUser
(
$user
)
->
setName
(
pht
(
'Purchase'
))
->
setHref
(
$cart_uri
)
->
setIcon
(
'new'
)
->
setRenderAsForm
(
true
));
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
setActionList
(
$actions
);
$crumbs
->
addCrumb
(
id
(
new
PhabricatorCrumbView
())
->
setName
(
pht
(
'Products'
))
->
setHref
(
$this
->
getApplicationURI
(
'product/'
)));
$crumbs
->
addCrumb
(
id
(
new
PhabricatorCrumbView
())
->
setName
(
pht
(
'#%d'
,
$product
->
getID
()))
->
setHref
(
$request
->
getRequestURI
()));
$properties
=
id
(
new
PhabricatorPropertyListView
())
->
setUser
(
$user
)
->
addProperty
(
pht
(
'Type'
),
$product
->
getTypeName
())
->
addProperty
(
pht
(
'Price'
),
PhortuneCurrency
::
newFromUSDCents
(
$product
->
getPriceInCents
())
->
formatForDisplay
());
$xactions
=
id
(
new
PhortuneProductTransactionQuery
())
->
setViewer
(
$user
)
->
withObjectPHIDs
(
array
(
$product
->
getPHID
()))
->
execute
();
$engine
=
id
(
new
PhabricatorMarkupEngine
())
->
setViewer
(
$user
);
$xaction_view
=
id
(
new
PhabricatorApplicationTransactionView
())
->
setUser
(
$user
)
->
setObjectPHID
(
$product
->
getPHID
())
->
setTransactions
(
$xactions
)
->
setMarkupEngine
(
$engine
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$header
,
$actions
,
$properties
,
$xaction_view
,
),
array
(
'title'
=>
$title
,
'device'
=>
true
,
));
}
}
Event Timeline
Log In to Comment