Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96184022
PhrictionDocumentPublishTransaction.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
Mon, Dec 23, 13:43
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 13:43 (2 d)
Engine
blob
Format
Raw Data
Handle
23133982
Attached To
rPH Phabricator
PhrictionDocumentPublishTransaction.php
View Options
<?php
final
class
PhrictionDocumentPublishTransaction
extends
PhrictionDocumentTransactionType
{
const
TRANSACTIONTYPE
=
'publish'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getContentPHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setContentPHID
(
$value
);
}
public
function
getActionName
()
{
return
pht
(
'Published'
);
}
public
function
getTitle
()
{
return
pht
(
'%s published a new version of this document.'
,
$this
->
renderAuthor
());
}
public
function
getTitleForFeed
()
{
return
pht
(
'%s published a new version of %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$actor
=
$this
->
getActor
();
$errors
=
array
();
foreach
(
$xactions
as
$xaction
)
{
$content_phid
=
$xaction
->
getNewValue
();
// If this isn't changing anything, skip it.
if
(
$content_phid
===
$object
->
getContentPHID
())
{
continue
;
}
$content
=
id
(
new
PhrictionContentQuery
())
->
setViewer
(
$actor
)
->
withPHIDs
(
array
(
$content_phid
))
->
executeOne
();
if
(!
$content
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Unable to load Content object with PHID "%s".'
,
$content_phid
),
$xaction
);
continue
;
}
if
(
$content
->
getDocumentPHID
()
!==
$object
->
getPHID
())
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Content object "%s" can not be published because it belongs '
.
'to a different document.'
,
$content_phid
));
continue
;
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment