Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93608204
AlmanacBindingServiceTransaction.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
Sat, Nov 30, 03:17
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Dec 2, 03:17 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
22675239
Attached To
rPH Phabricator
AlmanacBindingServiceTransaction.php
View Options
<?php
final
class
AlmanacBindingServiceTransaction
extends
AlmanacBindingTransactionType
{
const
TRANSACTIONTYPE
=
'almanac:binding:service'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getServicePHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setServicePHID
(
$value
);
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$service_phid
=
$object
->
getServicePHID
();
if
(
$this
->
isEmptyTextTransaction
(
$service_phid
,
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Bindings must have a service.'
));
}
foreach
(
$xactions
as
$xaction
)
{
if
(!
$this
->
isNewObject
())
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'The service for a binding can not be changed once it has '
.
'been created.'
),
$xaction
);
continue
;
}
$service_phid
=
$xaction
->
getNewValue
();
$services
=
id
(
new
AlmanacServiceQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$service_phid
))
->
execute
();
if
(!
$services
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'You can not bind a nonexistent or restricted service.'
),
$xaction
);
continue
;
}
$service
=
head
(
$services
);
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$this
->
getActor
(),
$service
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
if
(!
$can_edit
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'You can not bind a service which you do not have permission '
.
'to edit.'
));
continue
;
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment