Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92480572
DifferentialJIRAIssuesField.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, Nov 20, 16:21
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 22, 16:21 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22447967
Attached To
rPH Phabricator
DifferentialJIRAIssuesField.php
View Options
<?php
final
class
DifferentialJIRAIssuesField
extends
DifferentialStoredCustomField
{
public
function
getFieldKey
()
{
return
'phabricator:jira-issues'
;
}
public
function
getValueForStorage
()
{
return
json_encode
(
$this
->
getValue
());
}
public
function
setValueFromStorage
(
$value
)
{
$this
->
setValue
(
json_decode
(
$value
,
true
));
return
$this
;
}
public
function
getFieldName
()
{
return
pht
(
'JIRA Issues'
);
}
public
function
getFieldDescription
()
{
return
pht
(
'Lists associated JIRA issues.'
);
}
public
function
shouldAppearInPropertyView
()
{
return
true
;
}
public
function
renderPropertyViewLabel
()
{
return
$this
->
getFieldName
();
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
$xobjs
=
$this
->
loadDoorkeeperExternalObjects
();
if
(!
$xobjs
)
{
return
null
;
}
$links
=
array
();
foreach
(
$xobjs
as
$xobj
)
{
$links
[]
=
id
(
new
DoorkeeperTagView
())
->
setExternalObject
(
$xobj
);
}
return
phutil_implode_html
(
phutil_tag
(
'br'
),
$links
);
}
private
function
buildDoorkeeperRefs
()
{
$provider
=
PhabricatorAuthProviderOAuth1JIRA
::
getJIRAProvider
();
$refs
=
array
();
if
(
$this
->
getValue
())
{
foreach
(
$this
->
getValue
()
as
$jira_key
)
{
$refs
[]
=
id
(
new
DoorkeeperObjectRef
())
->
setApplicationType
(
DoorkeeperBridgeJIRA
::
APPTYPE_JIRA
)
->
setApplicationDomain
(
$provider
->
getProviderDomain
())
->
setObjectType
(
DoorkeeperBridgeJIRA
::
OBJTYPE_ISSUE
)
->
setObjectID
(
$jira_key
);
}
}
return
$refs
;
}
private
function
loadDoorkeeperExternalObjects
()
{
$refs
=
$this
->
buildDoorkeeperRefs
();
if
(!
$refs
)
{
return
array
();
}
$xobjs
=
id
(
new
DoorkeeperExternalObjectQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withObjectKeys
(
mpull
(
$refs
,
'getObjectKey'
))
->
execute
();
return
$xobjs
;
}
// TODO: Implement edit; this field is readonly for now.
}
Event Timeline
Log In to Comment