Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93178697
PholioMockNameTransaction.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
Tue, Nov 26, 19:30
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 19:30 (2 d)
Engine
blob
Format
Raw Data
Handle
22587302
Attached To
rPH Phabricator
PholioMockNameTransaction.php
View Options
<?php
final
class
PholioMockNameTransaction
extends
PholioMockTransactionType
{
const
TRANSACTIONTYPE
=
'name'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getName
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setName
(
$value
);
if
(
$object
->
getOriginalName
()
===
null
)
{
$object
->
setOriginalName
(
$this
->
getNewValue
());
}
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$old
===
null
)
{
return
pht
(
'%s created %s.'
,
$this
->
renderAuthor
(),
$this
->
renderValue
(
$new
));
}
else
{
return
pht
(
'%s renamed this mock from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderValue
(
$old
),
$this
->
renderValue
(
$new
));
}
}
public
function
getTitleForFeed
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$old
===
null
)
{
return
pht
(
'%s created %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
else
{
return
pht
(
'%s renamed %s from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderValue
(
$old
),
$this
->
renderValue
(
$new
));
}
}
public
function
getColor
()
{
$old
=
$this
->
getOldValue
();
if
(
$old
===
null
)
{
return
PhabricatorTransactions
::
COLOR_GREEN
;
}
return
parent
::
getColor
();
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getName
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Mocks 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
(
'Mock names must not be longer than %s character(s).'
,
new
PhutilNumber
(
$max_length
)));
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment