Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893117
AlmanacDeviceStatusTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
1 KB
Referenced Files
None
Subscribers
None
AlmanacDeviceStatusTransaction.php
View Options
<?php
final
class
AlmanacDeviceStatusTransaction
extends
AlmanacDeviceTransactionType
{
const
TRANSACTIONTYPE
=
'almanac:device:status'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getStatus
(
)
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setStatus
(
$value
)
;
}
public
function
getTitle
(
)
{
$old_value
=
$this
->
getOldValue
(
)
;
$new_value
=
$this
->
getNewValue
(
)
;
$old_status
=
AlmanacDeviceStatus
::
newStatusFromValue
(
$old_value
)
;
$new_status
=
AlmanacDeviceStatus
::
newStatusFromValue
(
$new_value
)
;
$old_name
=
$old_status
->
getName
(
)
;
$new_name
=
$new_status
->
getName
(
)
;
return
pht
(
'%s changed the status of this device from %s to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderValue
(
$old_name
)
,
$this
->
renderValue
(
$new_name
)
)
;
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
(
)
;
$status_map
=
AlmanacDeviceStatus
::
getStatusMap
(
)
;
$old_value
=
$this
->
generateOldValue
(
$object
)
;
foreach
(
$xactions
as
$xaction
)
{
$new_value
=
$xaction
->
getNewValue
(
)
;
if
(
$new_value
===
$old_value
)
{
continue
;
}
if
(
!
isset
(
$status_map
[
$new_value
]
)
)
{
$errors
[
]
=
$this
->
newInvalidError
(
pht
(
'Almanac device status "%s" is unrecognized. Valid status '
.
'values are: %s.'
,
$new_value
,
implode
(
', '
,
array_keys
(
$status_map
)
)
)
,
$xaction
)
;
continue
;
}
}
return
$errors
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 17:53 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127164
Default Alt Text
AlmanacDeviceStatusTransaction.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment