Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F116948069
AlmanacInterface.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, Jun 10, 11:00
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Jun 12, 11:00 (2 d)
Engine
blob
Format
Raw Data
Handle
26688233
Attached To
rPH Phabricator
AlmanacInterface.php
View Options
<?php
final
class
AlmanacInterface
extends
AlmanacDAO
implements
PhabricatorPolicyInterface
{
protected
$devicePHID
;
protected
$networkPHID
;
protected
$address
;
protected
$port
;
private
$device
=
self
::
ATTACHABLE
;
private
$network
=
self
::
ATTACHABLE
;
public
static
function
initializeNewInterface
()
{
return
id
(
new
AlmanacInterface
());
}
public
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'address'
=>
'text64'
,
'port'
=>
'uint32'
,
),
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_location'
=>
array
(
'columns'
=>
array
(
'networkPHID'
,
'address'
,
'port'
),
),
'key_device'
=>
array
(
'columns'
=>
array
(
'devicePHID'
),
),
),
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
AlmanacInterfacePHIDType
::
TYPECONST
);
}
public
function
getDevice
()
{
return
$this
->
assertAttached
(
$this
->
device
);
}
public
function
attachDevice
(
AlmanacDevice
$device
)
{
$this
->
device
=
$device
;
return
$this
;
}
public
function
getNetwork
()
{
return
$this
->
assertAttached
(
$this
->
network
);
}
public
function
attachNetwork
(
AlmanacNetwork
$device
)
{
$this
->
device
=
$device
;
return
$this
;
}
public
function
toAddress
()
{
return
AlmanacAddress
::
newFromParts
(
$this
->
getNetworkPHID
(),
$this
->
getAddress
(),
$this
->
getPort
());
}
public
function
getAddressHash
()
{
return
$this
->
toAddress
()->
toHash
();
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
return
$this
->
getDevice
()->
getPolicy
(
$capability
);
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
$this
->
getDevice
()->
hasAutomaticCapability
(
$capability
,
$viewer
);
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
array
(
pht
(
'An interface inherits the policies of the device it belongs to.'
),
pht
(
'You must be able to view the network an interface resides on to '
.
'view the interface.'
),
);
}
}
Event Timeline
Log In to Comment