Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91652942
AlmanacInterfaceNetworkTransaction.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
Wed, Nov 13, 03:00
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 15, 03:00 (2 d)
Engine
blob
Format
Raw Data
Handle
22287696
Attached To
rPH Phabricator
AlmanacInterfaceNetworkTransaction.php
View Options
<?php
final
class
AlmanacInterfaceNetworkTransaction
extends
AlmanacInterfaceTransactionType
{
const
TRANSACTIONTYPE
=
'almanac:interface:network'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getNetworkPHID
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setNetworkPHID
(
$value
);
}
public
function
getTitle
()
{
return
pht
(
'%s changed the network for this interface from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldHandle
(),
$this
->
renderNewHandle
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
$network_phid
=
$object
->
getNetworkPHID
();
if
(
$this
->
isEmptyTextTransaction
(
$network_phid
,
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Interfaces must have a network.'
));
}
foreach
(
$xactions
as
$xaction
)
{
$network_phid
=
$xaction
->
getNewValue
();
$networks
=
id
(
new
AlmanacNetworkQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$network_phid
))
->
execute
();
if
(!
$networks
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'You can not put an interface on a nonexistent or restricted '
.
'network.'
),
$xaction
);
continue
;
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment