Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892660
PhortuneProduct.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
PhortuneProduct.php
View Options
<?php
/**
* A product is something users can purchase.
*/
final
class
PhortuneProduct
extends
PhortuneDAO
implements
PhabricatorPolicyInterface
{
protected
$productClassKey
;
protected
$productClass
;
protected
$productRefKey
;
protected
$productRef
;
protected
$metadata
=
array
(
)
;
private
$implementation
=
self
::
ATTACHABLE
;
protected
function
getConfiguration
(
)
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_SERIALIZATION
=>
array
(
'metadata'
=>
self
::
SERIALIZATION_JSON
,
)
,
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'productClassKey'
=>
'bytes12'
,
'productClass'
=>
'text128'
,
'productRefKey'
=>
'bytes12'
,
'productRef'
=>
'text128'
,
)
,
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_product'
=>
array
(
'columns'
=>
array
(
'productClassKey'
,
'productRefKey'
)
,
'unique'
=>
true
,
)
,
)
,
)
+
parent
::
getConfiguration
(
)
;
}
public
function
generatePHID
(
)
{
return
PhabricatorPHID
::
generateNewPHID
(
PhortuneProductPHIDType
::
TYPECONST
)
;
}
public
static
function
initializeNewProduct
(
)
{
return
id
(
new
PhortuneProduct
(
)
)
;
}
public
function
attachImplementation
(
PhortuneProductImplementation
$impl
)
{
$this
->
implementation
=
$impl
;
}
public
function
getImplementation
(
)
{
return
$this
->
assertAttached
(
$this
->
implementation
)
;
}
public
function
save
(
)
{
$this
->
productClassKey
=
PhabricatorHash
::
digestForIndex
(
$this
->
productClass
)
;
$this
->
productRefKey
=
PhabricatorHash
::
digestForIndex
(
$this
->
productRef
)
;
return
parent
::
save
(
)
;
}
public
function
getPriceAsCurrency
(
)
{
return
$this
->
getImplementation
(
)
->
getPriceAsCurrency
(
$this
)
;
}
public
function
getProductName
(
)
{
return
$this
->
getImplementation
(
)
->
getName
(
$this
)
;
}
public
function
getPurchaseName
(
PhortunePurchase
$purchase
)
{
return
$this
->
getImplementation
(
)
->
getPurchaseName
(
$this
,
$purchase
)
;
}
public
function
didPurchaseProduct
(
PhortunePurchase
$purchase
)
{
return
$this
->
getImplementation
(
)
->
didPurchaseProduct
(
$this
,
$purchase
)
;
}
public
function
didRefundProduct
(
PhortunePurchase
$purchase
,
PhortuneCurrency
$amount
)
{
return
$this
->
getImplementation
(
)
->
didRefundProduct
(
$this
,
$purchase
,
$amount
)
;
}
public
function
getPurchaseURI
(
PhortunePurchase
$purchase
)
{
return
$this
->
getImplementation
(
)
->
getPurchaseURI
(
$this
,
$purchase
)
;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
(
)
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
)
;
}
public
function
getPolicy
(
$capability
)
{
return
PhabricatorPolicies
::
POLICY_USER
;
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 17:10 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1111227
Default Alt Text
PhortuneProduct.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment