Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86180281
AlmanacCoreCustomField.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
Fri, Oct 4, 18:31
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Oct 6, 18:31 (2 d)
Engine
blob
Format
Raw Data
Handle
21365482
Attached To
rPH Phabricator
AlmanacCoreCustomField.php
View Options
<?php
final
class
AlmanacCoreCustomField
extends
AlmanacCustomField
implements
PhabricatorStandardCustomFieldInterface
{
public
function
getStandardCustomFieldNamespace
()
{
return
'almanac:core'
;
}
public
function
getFieldKey
()
{
return
$this
->
getProxy
()->
getRawStandardFieldKey
();
}
public
function
getFieldName
()
{
return
$this
->
getFieldKey
();
}
public
function
createFields
(
$object
)
{
if
(!
$object
->
getID
())
{
return
array
();
}
$specs
=
$object
->
getAlmanacPropertyFieldSpecifications
();
$default_specs
=
array
();
foreach
(
$object
->
getAlmanacProperties
()
as
$property
)
{
$default_specs
[
$property
->
getFieldName
()]
=
array
(
'name'
=>
$property
->
getFieldName
(),
'type'
=>
'text'
,
);
}
return
PhabricatorStandardCustomField
::
buildStandardFields
(
$this
,
$specs
+
$default_specs
);
}
public
function
shouldUseStorage
()
{
return
false
;
}
public
function
readValueFromObject
(
PhabricatorCustomFieldInterface
$object
)
{
$key
=
$this
->
getFieldKey
();
if
(
$object
->
hasAlmanacProperty
(
$key
))
{
$this
->
setValueFromStorage
(
$object
->
getAlmanacPropertyValue
(
$key
));
}
}
public
function
applyApplicationTransactionInternalEffects
(
PhabricatorApplicationTransaction
$xaction
)
{
return
;
}
public
function
applyApplicationTransactionExternalEffects
(
PhabricatorApplicationTransaction
$xaction
)
{
$object
=
$this
->
getObject
();
$phid
=
$object
->
getPHID
();
$key
=
$this
->
getFieldKey
();
$property
=
id
(
new
AlmanacPropertyQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withObjectPHIDs
(
array
(
$phid
))
->
withNames
(
array
(
$key
))
->
executeOne
();
if
(!
$property
)
{
$property
=
id
(
new
AlmanacProperty
())
->
setObjectPHID
(
$phid
)
->
setFieldIndex
(
PhabricatorHash
::
digestForIndex
(
$key
))
->
setFieldName
(
$key
);
}
$property
->
setFieldValue
(
$xaction
->
getNewValue
())
->
save
();
}
}
Event Timeline
Log In to Comment