Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91208038
PhabricatorProjectColumnNameTransaction.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, Nov 8, 23:53
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 10, 23:53 (2 d)
Engine
blob
Format
Raw Data
Handle
22220419
Attached To
rPH Phabricator
PhabricatorProjectColumnNameTransaction.php
View Options
<?php
final
class
PhabricatorProjectColumnNameTransaction
extends
PhabricatorProjectColumnTransactionType
{
const
TRANSACTIONTYPE
=
'project:col:name'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getName
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setName
(
$value
);
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(!
strlen
(
$old
))
{
return
pht
(
'%s named this column %s.'
,
$this
->
renderAuthor
(),
$this
->
renderNewValue
());
}
else
if
(
strlen
(
$new
))
{
return
pht
(
'%s renamed this column from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
else
{
return
pht
(
'%s removed the custom name of this column.'
,
$this
->
renderAuthor
());
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getName
(),
$xactions
))
{
// The default "Backlog" column is allowed to be unnamed, which
// means we use the default name.
if
(!
$object
->
isDefaultColumn
())
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Columns must have a name.'
));
}
}
$max_length
=
$object
->
getColumnMaximumByteLength
(
'name'
);
foreach
(
$xactions
as
$xaction
)
{
$new_value
=
$xaction
->
getNewValue
();
$new_length
=
strlen
(
$new_value
);
if
(
$new_length
>
$max_length
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Column names must not be longer than %s characters.'
,
new
PhutilNumber
(
$max_length
)),
$xaction
);
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment