Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91623165
AlmanacInterfacePortTransaction.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
Tue, Nov 12, 20:24
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 14, 20:24 (2 d)
Engine
blob
Format
Raw Data
Handle
22290085
Attached To
rPH Phabricator
AlmanacInterfacePortTransaction.php
View Options
<?php
final
class
AlmanacInterfacePortTransaction
extends
AlmanacInterfaceTransactionType
{
const
TRANSACTIONTYPE
=
'almanac:interface:port'
;
public
function
generateOldValue
(
$object
)
{
$port
=
$object
->
getPort
();
if
(
$port
!==
null
)
{
$port
=
(
int
)
$port
;
}
return
$port
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setPort
((
int
)
$value
);
}
public
function
getTitle
()
{
return
pht
(
'%s changed the port for this interface from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getPort
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Interfaces must have a port number.'
));
}
foreach
(
$xactions
as
$xaction
)
{
$port
=
$xaction
->
getNewValue
();
$port
=
(
int
)
$port
;
if
(
$port
<
1
||
$port
>
65535
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'Port numbers must be between 1 and 65535, inclusive.'
),
$xaction
);
continue
;
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment