Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104783689
HeraldRuleEditor.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, Mar 12, 08:55
Size
2 KB
Mime Type
text/x-php
Expires
Fri, Mar 14, 08:55 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24852432
Attached To
rPH Phabricator
HeraldRuleEditor.php
View Options
<?php
final
class
HeraldRuleEditor
extends
PhabricatorApplicationTransactionEditor
{
public
function
getEditorApplicationClass
()
{
return
'PhabricatorHeraldApplication'
;
}
public
function
getEditorObjectsDescription
()
{
return
pht
(
'Herald Rules'
);
}
public
function
getTransactionTypes
()
{
$types
=
parent
::
getTransactionTypes
();
$types
[]
=
PhabricatorTransactions
::
TYPE_COMMENT
;
$types
[]
=
HeraldRuleTransaction
::
TYPE_EDIT
;
$types
[]
=
HeraldRuleTransaction
::
TYPE_NAME
;
$types
[]
=
HeraldRuleTransaction
::
TYPE_DISABLE
;
return
$types
;
}
protected
function
getCustomTransactionOldValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
HeraldRuleTransaction
::
TYPE_DISABLE
:
return
(
int
)
$object
->
getIsDisabled
();
case
HeraldRuleTransaction
::
TYPE_EDIT
:
return
id
(
new
HeraldRuleSerializer
())
->
serializeRule
(
$object
);
case
HeraldRuleTransaction
::
TYPE_NAME
:
return
$object
->
getName
();
}
}
protected
function
getCustomTransactionNewValue
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
HeraldRuleTransaction
::
TYPE_DISABLE
:
return
(
int
)
$xaction
->
getNewValue
();
case
HeraldRuleTransaction
::
TYPE_EDIT
:
case
HeraldRuleTransaction
::
TYPE_NAME
:
return
$xaction
->
getNewValue
();
}
}
protected
function
applyCustomInternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
HeraldRuleTransaction
::
TYPE_DISABLE
:
return
$object
->
setIsDisabled
(
$xaction
->
getNewValue
());
case
HeraldRuleTransaction
::
TYPE_NAME
:
return
$object
->
setName
(
$xaction
->
getNewValue
());
case
HeraldRuleTransaction
::
TYPE_EDIT
:
$new_state
=
id
(
new
HeraldRuleSerializer
())
->
deserializeRuleComponents
(
$xaction
->
getNewValue
());
$object
->
setMustMatchAll
((
int
)
$new_state
[
'match_all'
]);
$object
->
attachConditions
(
$new_state
[
'conditions'
]);
$object
->
attachActions
(
$new_state
[
'actions'
]);
$new_repetition
=
$new_state
[
'repetition_policy'
];
$object
->
setRepetitionPolicyStringConstant
(
$new_repetition
);
return
$object
;
}
}
protected
function
applyCustomExternalTransaction
(
PhabricatorLiskDAO
$object
,
PhabricatorApplicationTransaction
$xaction
)
{
switch
(
$xaction
->
getTransactionType
())
{
case
HeraldRuleTransaction
::
TYPE_EDIT
:
$object
->
saveConditions
(
$object
->
getConditions
());
$object
->
saveActions
(
$object
->
getActions
());
break
;
}
return
;
}
}
Event Timeline
Log In to Comment