Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F953181
HeraldPholioMockAdapter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
HeraldPholioMockAdapter.php
View Options
<?php
final
class
HeraldPholioMockAdapter
extends
HeraldAdapter
{
private
$mock
;
private
$ccPHIDs
=
array
();
public
function
getAdapterApplicationClass
()
{
return
'PhabricatorApplicationPholio'
;
}
public
function
getAdapterContentDescription
()
{
return
pht
(
'React to mocks being created or updated.'
);
}
public
function
getObject
()
{
return
$this
->
mock
;
}
public
function
setMock
(
PholioMock
$mock
)
{
$this
->
mock
=
$mock
;
return
$this
;
}
public
function
getMock
()
{
return
$this
->
mock
;
}
private
function
setCcPHIDs
(
array
$cc_phids
)
{
$this
->
ccPHIDs
=
$cc_phids
;
return
$this
;
}
public
function
getCcPHIDs
()
{
return
$this
->
ccPHIDs
;
}
public
function
getAdapterContentName
()
{
return
pht
(
'Pholio Mocks'
);
}
public
function
supportsRuleType
(
$rule_type
)
{
switch
(
$rule_type
)
{
case
HeraldRuleTypeConfig
::
RULE_TYPE_GLOBAL
:
case
HeraldRuleTypeConfig
::
RULE_TYPE_PERSONAL
:
return
true
;
case
HeraldRuleTypeConfig
::
RULE_TYPE_OBJECT
:
default
:
return
false
;
}
}
public
function
getFields
()
{
return
array_merge
(
array
(
self
::
FIELD_TITLE
,
self
::
FIELD_BODY
,
self
::
FIELD_AUTHOR
,
self
::
FIELD_CC
,
self
::
FIELD_PROJECTS
,
self
::
FIELD_IS_NEW_OBJECT
,
),
parent
::
getFields
());
}
public
function
getActions
(
$rule_type
)
{
switch
(
$rule_type
)
{
case
HeraldRuleTypeConfig
::
RULE_TYPE_GLOBAL
:
return
array_merge
(
array
(
self
::
ACTION_ADD_CC
,
self
::
ACTION_NOTHING
,
),
parent
::
getActions
(
$rule_type
));
case
HeraldRuleTypeConfig
::
RULE_TYPE_PERSONAL
:
return
array_merge
(
array
(
self
::
ACTION_ADD_CC
,
self
::
ACTION_FLAG
,
self
::
ACTION_NOTHING
,
),
parent
::
getActions
(
$rule_type
));
}
}
public
function
getPHID
()
{
return
$this
->
getMock
()->
getPHID
();
}
public
function
getHeraldName
()
{
return
'M'
.
$this
->
getMock
()->
getID
();
}
public
function
getHeraldField
(
$field
)
{
switch
(
$field
)
{
case
self
::
FIELD_TITLE
:
return
$this
->
getMock
()->
getName
();
case
self
::
FIELD_BODY
:
return
$this
->
getMock
()->
getDescription
();
case
self
::
FIELD_AUTHOR
:
return
$this
->
getMock
()->
getAuthorPHID
();
case
self
::
FIELD_CC
:
return
PhabricatorSubscribersQuery
::
loadSubscribersForPHID
(
$this
->
getMock
()->
getPHID
());
case
self
::
FIELD_PROJECTS
:
return
PhabricatorEdgeQuery
::
loadDestinationPHIDs
(
$this
->
getMock
()->
getPHID
(),
PhabricatorProjectObjectHasProjectEdgeType
::
EDGECONST
);
}
return
parent
::
getHeraldField
(
$field
);
}
public
function
applyHeraldEffects
(
array
$effects
)
{
assert_instances_of
(
$effects
,
'HeraldEffect'
);
$result
=
array
();
foreach
(
$effects
as
$effect
)
{
$action
=
$effect
->
getAction
();
switch
(
$action
)
{
case
self
::
ACTION_NOTHING
:
$result
[]
=
new
HeraldApplyTranscript
(
$effect
,
true
,
pht
(
'Great success at doing nothing.'
));
break
;
case
self
::
ACTION_ADD_CC
:
foreach
(
$effect
->
getTarget
()
as
$phid
)
{
$this
->
ccPHIDs
[]
=
$phid
;
}
$result
[]
=
new
HeraldApplyTranscript
(
$effect
,
true
,
pht
(
'Added address to cc list.'
));
break
;
case
self
::
ACTION_FLAG
:
$result
[]
=
parent
::
applyFlagEffect
(
$effect
,
$this
->
getMock
()->
getPHID
());
break
;
default
:
$custom_result
=
parent
::
handleCustomHeraldEffect
(
$effect
);
if
(
$custom_result
===
null
)
{
throw
new
Exception
(
"No rules to handle action '{$action}'."
);
}
$result
[]
=
$custom_result
;
break
;
}
}
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Jun 17, 3:57 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
226863
Default Alt Text
HeraldPholioMockAdapter.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment