Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92700532
PholioImageReplaceTransaction.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 22, 22:11
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 22:11 (1 d, 19 h)
Engine
blob
Format
Raw Data
Handle
22479363
Attached To
rPH Phabricator
PholioImageReplaceTransaction.php
View Options
<?php
final
class
PholioImageReplaceTransaction
extends
PholioImageTransactionType
{
const
TRANSACTIONTYPE
=
'image-replace'
;
public
function
generateOldValue
(
$object
)
{
$new_image
=
$this
->
getNewValue
();
return
$new_image
->
getReplacesImagePHID
();
}
public
function
generateNewValue
(
$object
,
$value
)
{
return
$value
->
getPHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$old
=
$this
->
getOldValue
();
$images
=
$object
->
getImages
();
foreach
(
$images
as
$seq
=>
$image
)
{
if
(
$image
->
getPHID
()
==
$old
)
{
$image
->
setIsObsolete
(
1
);
$image
->
save
();
unset
(
$images
[
$seq
]);
}
}
$object
->
attachImages
(
$images
);
}
public
function
getTitle
()
{
return
pht
(
'%s replaced %s with %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldHandle
(),
$this
->
renderNewHandle
());
}
public
function
getTitleForFeed
()
{
return
pht
(
'%s updated images of %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
public
function
getIcon
()
{
return
'fa-picture-o'
;
}
public
function
getColor
()
{
return
PhabricatorTransactions
::
COLOR_YELLOW
;
}
public
function
mergeTransactions
(
$object
,
PhabricatorApplicationTransaction
$u
,
PhabricatorApplicationTransaction
$v
)
{
$u_img
=
$u
->
getNewValue
();
$v_img
=
$v
->
getNewValue
();
if
(
$u_img
->
getReplacesImagePHID
()
==
$v_img
->
getReplacesImagePHID
())
{
return
$v
;
}
}
public
function
extractFilePHIDs
(
$object
,
$value
)
{
$file_phids
=
array
();
$editor
=
$this
->
getEditor
();
$images
=
$editor
->
getNewImages
();
foreach
(
$images
as
$image
)
{
if
(
$image
->
getPHID
()
!==
$value
)
{
continue
;
}
$file_phids
[]
=
$image
->
getFilePHID
();
}
return
$file_phids
;
}
}
Event Timeline
Log In to Comment