Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98090470
PhortuneAccountNameTransaction.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
Thu, Jan 9, 16:34
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Jan 11, 16:34 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23504877
Attached To
rPH Phabricator
PhortuneAccountNameTransaction.php
View Options
<?php
final
class
PhortuneAccountNameTransaction
extends
PhortuneAccountTransactionType
{
const
TRANSACTIONTYPE
=
'phortune: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
)
&&
strlen
(
$new
))
{
return
pht
(
'%s renamed this account from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
else
{
return
pht
(
'%s created this account.'
,
$this
->
renderAuthor
());
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getName
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Accounts 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
->
newRequiredError
(
pht
(
'The name can be no longer than %s characters.'
,
new
PhutilNumber
(
$max_length
)));
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment