Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104858457
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
Wed, Mar 12, 22:54
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Mar 14, 22:54 (2 d)
Engine
blob
Format
Raw Data
Handle
24867053
Attached To
rPH Phabricator
AlmanacCoreCustomField.php
View Options
<?php
final
class
AlmanacCoreCustomField
extends
AlmanacCustomField
implements
PhabricatorStandardCustomFieldInterface
{
public
function
getStandardCustomFieldNamespace
()
{
return
'almanac:core'
;
}
public
function
createFields
(
$object
)
{
$specs
=
array
();
foreach
(
$object
->
getAlmanacProperties
()
as
$property
)
{
$specs
[
$property
->
getFieldName
()]
=
array
(
'name'
=>
$property
->
getFieldName
(),
'type'
=>
'text'
,
);
}
return
PhabricatorStandardCustomField
::
buildStandardFields
(
$this
,
$specs
);
}
public
function
shouldUseStorage
()
{
return
false
;
}
public
function
readValueFromObject
(
PhabricatorCustomFieldInterface
$object
)
{
$key
=
$this
->
getProxy
()->
getRawStandardFieldKey
();
$this
->
setValueFromStorage
(
$object
->
getAlmanacPropertyValue
(
$key
));
}
public
function
applyApplicationTransactionInternalEffects
(
PhabricatorApplicationTransaction
$xaction
)
{
return
;
}
public
function
applyApplicationTransactionExternalEffects
(
PhabricatorApplicationTransaction
$xaction
)
{
$object
=
$this
->
getObject
();
$phid
=
$object
->
getPHID
();
$key
=
$this
->
getProxy
()->
getRawStandardFieldKey
();
$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