Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104158553
NuanceSource.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
Thu, Mar 6, 20:57
Size
3 KB
Mime Type
text/x-php
Expires
Sat, Mar 8, 20:57 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24756577
Attached To
rPH Phabricator
NuanceSource.php
View Options
<?php
final
class
NuanceSource
extends
NuanceDAO
implements
PhabricatorApplicationTransactionInterface
,
PhabricatorPolicyInterface
{
protected
$name
;
protected
$type
;
protected
$data
;
protected
$mailKey
;
protected
$viewPolicy
;
protected
$editPolicy
;
protected
$defaultQueuePHID
;
private
$definition
;
protected
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_SERIALIZATION
=>
array
(
'data'
=>
self
::
SERIALIZATION_JSON
,
),
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'name'
=>
'text255?'
,
'type'
=>
'text32'
,
'mailKey'
=>
'bytes20'
,
),
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_type'
=>
array
(
'columns'
=>
array
(
'type'
,
'dateModified'
),
),
),
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
NuanceSourcePHIDType
::
TYPECONST
);
}
public
function
save
()
{
if
(!
$this
->
getMailKey
())
{
$this
->
setMailKey
(
Filesystem
::
readRandomCharacters
(
20
));
}
return
parent
::
save
();
}
public
function
getURI
()
{
return
'/nuance/source/view/'
.
$this
->
getID
().
'/'
;
}
public
static
function
initializeNewSource
(
PhabricatorUser
$actor
)
{
$app
=
id
(
new
PhabricatorApplicationQuery
())
->
setViewer
(
$actor
)
->
withClasses
(
array
(
'PhabricatorNuanceApplication'
))
->
executeOne
();
$view_policy
=
$app
->
getPolicy
(
NuanceSourceDefaultViewCapability
::
CAPABILITY
);
$edit_policy
=
$app
->
getPolicy
(
NuanceSourceDefaultEditCapability
::
CAPABILITY
);
return
id
(
new
NuanceSource
())
->
setViewPolicy
(
$view_policy
)
->
setEditPolicy
(
$edit_policy
);
}
public
function
getDefinition
()
{
if
(
$this
->
definition
===
null
)
{
$definitions
=
NuanceSourceDefinition
::
getAllDefinitions
();
if
(
isset
(
$definitions
[
$this
->
getType
()]))
{
$definition
=
clone
$definitions
[
$this
->
getType
()];
$definition
->
setSourceObject
(
$this
);
$this
->
definition
=
$definition
;
}
}
return
$this
->
definition
;
}
public
function
requireDefinition
()
{
$definition
=
$this
->
getDefinition
();
if
(!
$definition
)
{
throw
new
Exception
(
pht
(
'Unable to load source definition implementation for source '
.
'type "%s".'
,
$this
->
getType
()));
}
return
$definition
;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public
function
getApplicationTransactionEditor
()
{
return
new
NuanceSourceEditor
();
}
public
function
getApplicationTransactionObject
()
{
return
$this
;
}
public
function
getApplicationTransactionTemplate
()
{
return
new
NuanceSourceTransaction
();
}
public
function
willRenderTimeline
(
PhabricatorApplicationTransactionView
$timeline
,
AphrontRequest
$request
)
{
return
$timeline
;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
switch
(
$capability
)
{
case
PhabricatorPolicyCapability
::
CAN_VIEW
:
return
$this
->
getViewPolicy
();
case
PhabricatorPolicyCapability
::
CAN_EDIT
:
return
$this
->
getEditPolicy
();
}
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
false
;
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
null
;
}
}
Event Timeline
Log In to Comment