Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96351486
FundBackerCart.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, Dec 25, 18:16
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Dec 27, 18:16 (1 d, 12 h)
Engine
blob
Format
Raw Data
Handle
23145334
Attached To
rPH Phabricator
FundBackerCart.php
View Options
<?php
final
class
FundBackerCart
extends
PhortuneCartImplementation
{
private
$initiativePHID
;
private
$initiative
;
public
function
setInitiativePHID
(
$initiative_phid
)
{
$this
->
initiativePHID
=
$initiative_phid
;
return
$this
;
}
public
function
getInitiativePHID
()
{
return
$this
->
initiativePHID
;
}
public
function
setInitiative
(
FundInitiative
$initiative
)
{
$this
->
initiative
=
$initiative
;
return
$this
;
}
public
function
getInitiative
()
{
return
$this
->
initiative
;
}
public
function
getName
(
PhortuneCart
$cart
)
{
return
pht
(
'Fund Initiative'
);
}
public
function
willCreateCart
(
PhabricatorUser
$viewer
,
PhortuneCart
$cart
)
{
$initiative
=
$this
->
getInitiative
();
if
(!
$initiative
)
{
throw
new
PhutilInvalidStateException
(
'setInitiative'
);
}
$cart
->
setMetadataValue
(
'initiativePHID'
,
$initiative
->
getPHID
());
}
public
function
loadImplementationsForCarts
(
PhabricatorUser
$viewer
,
array
$carts
)
{
$phids
=
array
();
foreach
(
$carts
as
$cart
)
{
$phids
[]
=
$cart
->
getMetadataValue
(
'initiativePHID'
);
}
$initiatives
=
id
(
new
FundInitiativeQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
$phids
)
->
execute
();
$initiatives
=
mpull
(
$initiatives
,
null
,
'getPHID'
);
$objects
=
array
();
foreach
(
$carts
as
$key
=>
$cart
)
{
$initiative_phid
=
$cart
->
getMetadataValue
(
'initiativePHID'
);
$object
=
id
(
new
FundBackerCart
())
->
setInitiativePHID
(
$initiative_phid
);
$initiative
=
idx
(
$initiatives
,
$initiative_phid
);
if
(
$initiative
)
{
$object
->
setInitiative
(
$initiative
);
}
$objects
[
$key
]
=
$object
;
}
return
$objects
;
}
public
function
getCancelURI
(
PhortuneCart
$cart
)
{
return
'/'
.
$this
->
getInitiative
()->
getMonogram
();
}
public
function
getDoneURI
(
PhortuneCart
$cart
)
{
return
'/'
.
$this
->
getInitiative
()->
getMonogram
();
}
public
function
getDoneActionName
(
PhortuneCart
$cart
)
{
return
pht
(
'Return to Initiative'
);
}
}
Event Timeline
Log In to Comment