Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F443803
DifferentialTitleFieldSpecification.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DifferentialTitleFieldSpecification.php
View Options
<?php
final
class
DifferentialTitleFieldSpecification
extends
DifferentialFreeformFieldSpecification
{
private
$title
;
private
$error
=
true
;
public
function
shouldAppearOnEdit
()
{
return
true
;
}
protected
function
didSetRevision
()
{
$this
->
title
=
$this
->
getRevision
()->
getTitle
();
}
public
function
setValueFromRequest
(
AphrontRequest
$request
)
{
$this
->
title
=
$request
->
getStr
(
'title'
);
$this
->
error
=
null
;
return
$this
;
}
public
function
renderEditControl
()
{
return
id
(
new
AphrontFormTextAreaControl
())
->
setLabel
(
'Title'
)
->
setName
(
'title'
)
->
setHeight
(
AphrontFormTextAreaControl
::
HEIGHT_VERY_SHORT
)
->
setError
(
$this
->
error
)
->
setValue
(
$this
->
title
);
}
public
function
shouldExtractMentions
()
{
return
true
;
}
public
function
willWriteRevision
(
DifferentialRevisionEditor
$editor
)
{
$this
->
getRevision
()->
setTitle
(
$this
->
title
);
}
public
function
validateField
()
{
if
(!
strlen
(
$this
->
title
))
{
$this
->
error
=
'Required'
;
throw
new
DifferentialFieldValidationException
(
"You must provide a revision title in the first line "
.
"of your commit message."
);
}
if
(
preg_match
(
'/^<<.*>>$/'
,
$this
->
title
))
{
$default_title
=
self
::
getDefaultRevisionTitle
();
$this
->
error
=
'Required'
;
throw
new
DifferentialFieldValidationException
(
"Replace the line '{$default_title}' with a revision title "
.
"that describes the change."
);
}
}
public
function
shouldAppearOnCommitMessage
()
{
return
true
;
}
public
function
getCommitMessageKey
()
{
return
'title'
;
}
public
function
setValueFromParsedCommitMessage
(
$value
)
{
$this
->
title
=
$value
;
return
$this
;
}
public
function
shouldOverwriteWhenCommitMessageIsEdited
()
{
return
true
;
}
public
function
renderLabelForCommitMessage
()
{
return
'Title'
;
}
public
function
renderValueForCommitMessage
(
$is_edit
)
{
return
$this
->
title
;
}
public
function
parseValueFromCommitMessage
(
$value
)
{
return
preg_replace
(
'/
\s
*
\n\s
*/'
,
' '
,
$value
);
}
public
function
shouldAppearOnRevisionList
()
{
return
true
;
}
public
function
renderHeaderForRevisionList
()
{
return
'Revision'
;
}
public
function
getColumnClassForRevisionList
()
{
return
'wide pri'
;
}
public
static
function
getDefaultRevisionTitle
()
{
return
'<<Replace this line with your Revision Title>>'
;
}
public
function
renderValueForRevisionList
(
DifferentialRevision
$revision
)
{
return
phutil_tag
(
'a'
,
array
(
'href'
=>
'/D'
.
$revision
->
getID
(),
),
$revision
->
getTitle
());
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, May 4, 11:06 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
64954
Default Alt Text
DifferentialTitleFieldSpecification.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment