Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2893712
SemiStructuredObjectType.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
5 KB
Referenced Files
None
Subscribers
None
SemiStructuredObjectType.php
View Options
<?php
final
class
SemiStructuredObjectType
extends
SemiStructuredDAO
implements
PhabricatorPolicyInterface
,
PhabricatorApplicationTransactionInterface
,
// PhabricatorMarkupInterface, ?
PhabricatorMentionableInterface
,
PhabricatorSubscribableInterface
,
PhabricatorProjectInterface
,
PhabricatorConduitResultInterface
,
PhabricatorFlaggableInterface
,
PhabricatorDestructibleInterface
,
PhabricatorFerretInterface
,
PhabricatorFulltextInterface
{
protected
$viewPolicy
;
protected
$editPolicy
;
protected
$name
;
protected
$status
;
protected
$description
;
protected
$customFieldsConfig
=
array
(
)
;
// icon/logo
const
STATUS_ACTIVE
=
'active'
;
const
STATUS_ARCHIVED
=
'archived'
;
public
static
function
initializeNewObjectType
(
PhabricatorUser
$actor
)
{
return
id
(
new
self
(
)
)
->
setName
(
''
)
->
setViewPolicy
(
PhabricatorPolicies
::
getMostOpenPolicy
(
)
)
->
setEditPolicy
(
$actor
->
getPHID
(
)
)
->
setStatus
(
self
::
STATUS_ACTIVE
)
;
}
public
function
getCustomFieldsConfig
(
)
{
if
(
!
$this
->
customFieldsConfig
)
{
return
array
(
)
;
}
return
$this
->
customFieldsConfig
;
}
public
static
function
getStatusNameMap
(
)
{
return
array
(
self
::
STATUS_ACTIVE
=>
pht
(
'Active'
)
,
self
::
STATUS_ARCHIVED
=>
pht
(
'Archived'
)
,
)
;
}
protected
function
getConfiguration
(
)
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_SERIALIZATION
=>
array
(
'customFieldsConfig'
=>
self
::
SERIALIZATION_JSON
,
)
,
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'name'
=>
'sort255'
,
'status'
=>
'text32'
,
'description'
=>
'text'
,
)
,
)
+
parent
::
getConfiguration
(
)
;
}
public
function
getPHIDType
(
)
{
return
SemiStructuredObjectTypePHIDType
::
TYPECONST
;
}
public
function
isArchived
(
)
{
return
(
$this
->
getStatus
(
)
==
self
::
STATUS_ARCHIVED
)
;
}
public
function
getURI
(
)
{
return
urisprintf
(
'/semistruct/type/%d/'
,
$this
->
getID
(
)
)
;
}
public
function
getObjectName
(
)
{
return
pht
(
'Object Type %d'
,
$this
->
getID
(
)
)
;
}
public
function
getIcon
(
)
{
// TODO copy the feature from Projects, where you can put a custom image
// or select from a list.
return
SemiStructuredDataApplication
::
ICON_OBJECT_TYPE
;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public
function
getApplicationTransactionEditor
(
)
{
return
new
SemiStructuredObjectTypeTransactionEditor
(
)
;
}
public
function
getApplicationTransactionTemplate
(
)
{
return
new
SemiStructuredObjectTypeTransaction
(
)
;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
(
)
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
// TODO can-create-instances
)
;
}
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
;
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public
function
getFieldSpecificationsForConduit
(
)
{
return
array
(
(
new
PhabricatorConduitSearchFieldSpecification
(
)
)
->
setKey
(
'name'
)
->
setType
(
'string'
)
->
setDescription
(
pht
(
'The name of the object type.'
)
)
,
(
new
PhabricatorConduitSearchFieldSpecification
(
)
)
->
setKey
(
'description'
)
->
setType
(
'remarkup'
)
->
setDescription
(
pht
(
'The description.'
)
)
,
(
new
PhabricatorConduitSearchFieldSpecification
(
)
)
->
setKey
(
'status'
)
->
setType
(
'string'
)
->
setDescription
(
pht
(
'Status of this object data.'
)
)
,
(
new
PhabricatorConduitSearchFieldSpecification
(
)
)
->
setKey
(
'customFieldsConfig'
)
->
setType
(
'map<string, wild>'
)
->
setDescription
(
pht
(
'Custom Fields definition'
)
)
,
)
;
}
public
function
getFieldValuesForConduit
(
)
{
return
array
(
'name'
=>
$this
->
getName
(
)
,
'description'
=>
array
(
'raw'
=>
$this
->
getDescription
(
)
,
)
,
'status'
=>
$this
->
getStatus
(
)
,
'customFieldsConfig'
=>
$this
->
getCustomFieldsConfig
(
)
,
)
;
}
public
function
getConduitSearchAttachments
(
)
{
return
array
(
)
;
}
/* -( PhabricatorFerretInterface )----------------------------------------- */
public
function
newFerretEngine
(
)
{
return
new
SemiStructuredObjectTypeFerretEngine
(
)
;
}
/* -( PhabricatorFulltextInterface )--------------------------------------- */
public
function
newFulltextEngine
(
)
{
return
new
SemiStructuredObjectTypeFulltextEngine
(
)
;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */
public
function
destroyObjectPermanently
(
PhabricatorDestructionEngine
$engine
)
{
$this
->
openTransaction
(
)
;
$this
->
delete
(
)
;
$this
->
saveTransaction
(
)
;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */
public
function
isAutomaticallySubscribed
(
$phid
)
{
return
false
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 18:56 (1 d, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1127608
Default Alt Text
SemiStructuredObjectType.php (5 KB)
Attached To
Mode
R6 Semi Structured
Attached
Detach File
Event Timeline
Log In to Comment