Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1819
PhabricatorCommitChangeIDField.php
Active
Public
Actions
Authored by
20after4
on Jul 7 2015, 5:34 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
Diffusion
Wikimedia
Referenced Files
F596292: PhabricatorCommitChangeIDField.php
Jul 7 2015, 5:34 PM
2015-07-07 17:34:56 (UTC+0)
Subscribers
None
<?php
final
class
PhabricatorCommitChangeIDField
extends
PhabricatorCommitCustomField
{
private
$value
;
public
function
getValue
()
{
return
$this
->
value
;
}
public
function
setValue
(
$value
)
{
$this
->
value
=
$value
;
return
$this
;
}
public
function
getFieldKey
()
{
return
'gerrit:change-id'
;
}
public
function
getFieldKeyForConduit
()
{
return
'changeID'
;
}
public
function
getFieldName
()
{
return
pht
(
'Change-Id'
);
}
public
function
getFieldDescription
()
{
return
pht
(
'Ties commits to gerrit changes and provides a permanent link between them.'
);
}
public
function
canDisableField
()
{
return
true
;
}
public
function
shouldDisableByDefault
()
{
return
true
;
}
public
function
shouldAppearInTransactionMail
()
{
return
true
;
}
public
function
getValueForStorage
()
{
return
json_encode
(
$this
->
getValue
());
}
public
function
setValueFromStorage
(
$value
)
{
try
{
$this
->
setValue
(
phutil_json_decode
(
$value
));
}
catch
(
PhutilJSONParserException
$ex
)
{
$this
->
setValue
(
array
());
}
return
$this
;
}
public
function
readValueFromRequest
(
AphrontRequest
$request
)
{
$this
->
setValue
(
$request
->
getStrList
(
$this
->
getFieldKey
()));
return
$this
;
}
public
function
shouldAppearInPropertyView
()
{
return
true
;
}
public
function
renderPropertyViewLabel
()
{
return
$this
->
getFieldName
();
}
public
function
renderPropertyViewValue
(
array
$handles
)
{
$links
=
array
();
foreach
(
$this
->
getValue
()
as
$value
)
{
$url
=
'https://gerrit.wikimedia.org/r/#q,'
.
$value
.
',n,z'
;
$links
[]
=
phutil_tag
(
'a'
,
array
(
'href'
=>
$url
,
'title'
=>
pht
(
'View Change in Gerrit'
),
'target'
=>
'_blank'
),
$value
);
}
return
phutil_tag
(
'span'
,
array
(),
$links
);
}
public
function
shouldAppearInCommitMessage
()
{
return
true
;
}
public
function
parseValueFromCommitMessage
(
$value
)
{
return
preg_split
(
'/[
\s
,]+/'
,
$value
,
$limit
=
-
1
,
PREG_SPLIT_NO_EMPTY
);
}
public
function
renderCommitMessageValue
(
array
$handles
)
{
return
$this
->
getValue
();
}
public
function
readValueFromCommitMessage
(
$value
)
{
$this
->
setValue
(
$value
);
return
$this
;
}
public
function
shouldAppearInApplicationTransactions
()
{
return
true
;
}
public
function
getOldValueForApplicationTransactions
()
{
return
$this
->
getValue
();
}
public
function
getNewValueForApplicationTransactions
()
{
return
$this
->
getValue
();
}
}
Event Timeline
20after4
edited the content of this paste.
(Show Details)
Jul 7 2015, 5:34 PM
2015-07-07 17:34:56 (UTC+0)
20after4
changed the title of this paste from untitled to
PhabricatorCommitChangeIDField.php
.
20after4
updated the paste's language from
autodetect
to
autodetect
.
20after4
changed the edit policy from "All Users" to "
20after4 (Mukunda Modell)
".
20after4
added projects:
Diffusion
,
Wikimedia
.
20after4
mentioned this in
D13581: Support custom fields in diffusion commit property views.
.
Jul 7 2015, 5:42 PM
2015-07-07 17:42:08 (UTC+0)
Log In to Comment