Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F79858148
PhortuneProduct.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
Wed, Aug 28, 15:38
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Aug 30, 15:38 (2 d)
Engine
blob
Format
Raw Data
Handle
20247159
Attached To
rPH Phabricator
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
;
public
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
)
{
return
$this
->
getImplementation
()->
didRefundProduct
(
$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
;
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
null
;
}
}
Event Timeline
Log In to Comment