Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F531718
PhabricatorPackagesPackagePublisherTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorPackagesPackagePublisherTransaction.php
View Options
<?php
final
class
PhabricatorPackagesPackagePublisherTransaction
extends
PhabricatorPackagesPackageTransactionType
{
const
TRANSACTIONTYPE
=
'packages.package.publisher'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getPublisherPHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setPublisherPHID
(
$value
);
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$current_value
=
$object
->
getPublisherPHID
();
if
(
$this
->
isEmptyTextTransaction
(
$current_value
,
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'You must select a publisher when creating a package.'
));
return
$errors
;
}
if
(!
$this
->
isNewObject
())
{
foreach
(
$xactions
as
$xaction
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Once a package is created, its publisher can not be changed.'
),
$xaction
);
}
}
$viewer
=
$this
->
getActor
();
foreach
(
$xactions
as
$xaction
)
{
$publisher_phid
=
$xaction
->
getNewValue
();
$publisher
=
id
(
new
PhabricatorPackagesPublisherQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$publisher_phid
))
->
setRaisePolicyExceptions
(
false
)
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$publisher
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Publisher "%s" is invalid: the publisher must exist and you '
.
'must have permission to edit it in order to create a new '
.
'package.'
,
$publisher_phid
),
$xaction
);
continue
;
}
$object
->
attachPublisher
(
$publisher
);
}
return
$errors
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 4:02 AM (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
105105
Default Alt Text
PhabricatorPackagesPackagePublisherTransaction.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment