Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100489609
ConduitAPI_flag_edit_Method.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
Fri, Jan 31, 05:13
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 2, 05:13 (2 d)
Engine
blob
Format
Raw Data
Handle
23975997
Attached To
rPH Phabricator
ConduitAPI_flag_edit_Method.php
View Options
<?php
/**
* @group conduit
*/
final
class
ConduitAPI_flag_edit_Method
extends
ConduitAPI_flag_Method
{
public
function
getMethodDescription
()
{
return
'Create or modify a flag.'
;
}
public
function
defineParamTypes
()
{
return
array
(
'objectPHID'
=>
'required phid'
,
'color'
=>
'optional int'
,
'note'
=>
'optional string'
,
);
}
public
function
defineReturnType
()
{
return
'dict'
;
}
public
function
defineErrorTypes
()
{
return
array
(
);
}
protected
function
execute
(
ConduitAPIRequest
$request
)
{
$user
=
$request
->
getUser
()->
getPHID
();
$phid
=
$request
->
getValue
(
'objectPHID'
);
$new
=
false
;
$flag
=
id
(
new
PhabricatorFlag
())->
loadOneWhere
(
'objectPHID = %s AND ownerPHID = %s'
,
$phid
,
$user
);
if
(
$flag
)
{
$params
=
$request
->
getAllParameters
();
if
(
isset
(
$params
[
'color'
]))
{
$flag
->
setColor
(
$params
[
'color'
]);
}
if
(
isset
(
$params
[
'note'
]))
{
$flag
->
setNote
(
$params
[
'note'
]);
}
}
else
{
$default_color
=
PhabricatorFlagColor
::
COLOR_BLUE
;
$flag
=
id
(
new
PhabricatorFlag
())
->
setOwnerPHID
(
$user
)
->
setType
(
phid_get_type
(
$phid
))
->
setObjectPHID
(
$phid
)
->
setReasonPHID
(
$user
)
->
setColor
(
$request
->
getValue
(
'color'
,
$default_color
))
->
setNote
(
$request
->
getValue
(
'note'
,
''
));
$new
=
true
;
}
$this
->
attachHandleToFlag
(
$flag
,
$request
->
getUser
());
$flag
->
save
();
$ret
=
$this
->
buildFlagInfoDictionary
(
$flag
);
$ret
[
'new'
]
=
$new
;
return
$ret
;
}
}
Event Timeline
Log In to Comment