Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98780824
FundInitiativeBackerTransaction.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
Thu, Jan 16, 10:00
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Jan 18, 10:00 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
23644662
Attached To
rPH Phabricator
FundInitiativeBackerTransaction.php
View Options
<?php
final
class
FundInitiativeBackerTransaction
extends
FundInitiativeTransactionType
{
const
TRANSACTIONTYPE
=
'fund:backer'
;
public
function
generateOldValue
(
$object
)
{
return
null
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$amount
=
$this
->
getMetadataValue
(
FundInitiativeTransaction
::
PROPERTY_AMOUNT
);
$amount
=
PhortuneCurrency
::
newFromString
(
$amount
);
$total
=
$object
->
getTotalAsCurrency
()->
add
(
$amount
);
$object
->
setTotalAsCurrency
(
$total
);
}
public
function
applyExternalEffects
(
$object
,
$value
)
{
$backer
=
id
(
new
FundBackerQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$value
))
->
executeOne
();
if
(!
$backer
)
{
throw
new
Exception
(
pht
(
'Unable to load %s!'
,
'FundBacker'
));
}
$subx
=
array
();
$subx
[]
=
id
(
new
FundBackerTransaction
())
->
setTransactionType
(
FundBackerStatusTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
FundBacker
::
STATUS_PURCHASED
);
$content_source
=
$this
->
getEditor
()->
getContentSource
();
$editor
=
id
(
new
FundBackerEditor
())
->
setActor
(
$this
->
getActor
())
->
setContentSource
(
$content_source
)
->
setContinueOnMissingFields
(
true
)
->
setContinueOnNoEffect
(
true
);
$editor
->
applyTransactions
(
$backer
,
$subx
);
}
public
function
getTitle
()
{
$amount
=
$this
->
getMetadataValue
(
FundInitiativeTransaction
::
PROPERTY_AMOUNT
);
$amount
=
PhortuneCurrency
::
newFromString
(
$amount
);
return
pht
(
'%s backed this initiative with %s.'
,
$this
->
renderAuthor
(),
$amount
->
formatForDisplay
());
}
public
function
getTitleForFeed
()
{
$amount
=
$this
->
getMetadataValue
(
FundInitiativeTransaction
::
PROPERTY_AMOUNT
);
$amount
=
PhortuneCurrency
::
newFromString
(
$amount
);
return
pht
(
'%s backed %s with %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$amount
->
formatForDisplay
());
}
public
function
getIcon
()
{
return
'fa-heart'
;
}
public
function
getColor
()
{
return
'red'
;
}
}
Event Timeline
Log In to Comment