Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F429001
PholioImageNameTransaction.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
PholioImageNameTransaction.php
View Options
<?php
final
class
PholioImageNameTransaction
extends
PholioImageTransactionType
{
const
TRANSACTIONTYPE
=
'image-name'
;
public
function
generateOldValue
(
$object
)
{
$name
=
null
;
$phid
=
null
;
$image
=
$this
->
getImageForXaction
(
$object
);
if
(
$image
)
{
$name
=
$image
->
getName
();
$phid
=
$image
->
getPHID
();
}
return
array
(
$phid
=>
$name
);
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$image
=
$this
->
getImageForXaction
(
$object
);
$value
=
(
string
)
head
(
$this
->
getNewValue
());
$image
->
setName
(
$value
);
$image
->
save
();
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
return
pht
(
'%s renamed an image (%s) from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderHandle
(
key
(
$new
)),
$this
->
renderValue
((
string
)
head
(
$old
)),
$this
->
renderValue
((
string
)
head
(
$new
)));
}
public
function
getTitleForFeed
()
{
return
pht
(
'%s updated the image names of %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
public
function
mergeTransactions
(
$object
,
PhabricatorApplicationTransaction
$u
,
PhabricatorApplicationTransaction
$v
)
{
$raw_new_value_u
=
$u
->
getNewValue
();
$raw_new_value_v
=
$v
->
getNewValue
();
$phid_u
=
head_key
(
$raw_new_value_u
);
$phid_v
=
head_key
(
$raw_new_value_v
);
if
(
$phid_u
==
$phid_v
)
{
return
$v
;
}
return
null
;
}
public
function
shouldHide
()
{
$old
=
$this
->
getOldValue
();
return
(
$old
===
array
(
null
=>
null
));
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$max_length
=
$object
->
getColumnMaximumByteLength
(
'name'
);
foreach
(
$xactions
as
$xaction
)
{
$new_value
=
head
(
array_values
(
$xaction
->
getNewValue
()));
$new_length
=
strlen
(
$new_value
);
if
(
$new_length
>
$max_length
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Mock image names must not be longer than %s character(s).'
,
new
PhutilNumber
(
$max_length
)));
}
}
return
$errors
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 3, 7:36 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
59345
Default Alt Text
PholioImageNameTransaction.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment