Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100823459
DifferentialSetDiffPropertyConduitAPIMethod.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, Feb 3, 01:43
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Feb 5, 01:43 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
23986031
Attached To
rPH Phabricator
DifferentialSetDiffPropertyConduitAPIMethod.php
View Options
<?php
final
class
DifferentialSetDiffPropertyConduitAPIMethod
extends
DifferentialConduitAPIMethod
{
public
function
getAPIMethodName
()
{
return
'differential.setdiffproperty'
;
}
public
function
getMethodDescription
()
{
return
pht
(
'Attach properties to Differential diffs.'
);
}
protected
function
defineParamTypes
()
{
return
array
(
'diff_id'
=>
'required diff_id'
,
'name'
=>
'required string'
,
'data'
=>
'required string'
,
);
}
protected
function
defineReturnType
()
{
return
'void'
;
}
protected
function
defineErrorTypes
()
{
return
array
(
'ERR_NOT_FOUND'
=>
pht
(
'Diff was not found.'
),
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$diff_id
=
$request
->
getValue
(
'diff_id'
);
$name
=
$request
->
getValue
(
'name'
);
$data
=
json_decode
(
$request
->
getValue
(
'data'
),
true
);
self
::
updateDiffProperty
(
$diff_id
,
$name
,
$data
);
}
private
static
function
updateDiffProperty
(
$diff_id
,
$name
,
$data
)
{
$property
=
id
(
new
DifferentialDiffProperty
())->
loadOneWhere
(
'diffID = %d AND name = %s'
,
$diff_id
,
$name
);
if
(!
$property
)
{
$property
=
new
DifferentialDiffProperty
();
$property
->
setDiffID
(
$diff_id
);
$property
->
setName
(
$name
);
}
$property
->
setData
(
$data
);
$property
->
save
();
return
$property
;
}
}
Event Timeline
Log In to Comment